Browse Source

Create user model

Lee Morgan 1 month ago
parent
commit
c8cf282637
5 changed files with 18 additions and 0 deletions
  1. 4 0
      Cargo.lock
  2. 2 0
      Cargo.toml
  3. 1 0
      src/main.rs
  4. 1 0
      src/models/mod.rs
  5. 10 0
      src/models/user.rs

+ 4 - 0
Cargo.lock

@@ -388,10 +388,12 @@ version = "0.1.0"
 dependencies = [
  "actix-cors",
  "actix-web",
+ "chrono",
  "dotenvy",
  "serde",
  "sqlx",
  "thiserror",
+ "uuid",
 ]
 
 [[package]]
@@ -401,7 +403,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
 dependencies = [
  "iana-time-zone",
+ "js-sys",
  "num-traits",
+ "wasm-bindgen",
  "windows-link",
 ]
 

+ 2 - 0
Cargo.toml

@@ -6,6 +6,7 @@ edition = "2024"
 [dependencies]
 actix-cors = "0.7.1"
 actix-web = "4.13.0"
+chrono = { version = "0.4.44" features = ["serde"]}
 dotenvy = "0.15.7"
 serde = { version = "1.0.228", features = ["derive"]}
 sqlx = { version = "0.8.6", features = [
@@ -16,3 +17,4 @@ sqlx = { version = "0.8.6", features = [
     "uuid"
 ]}
 thiserror = "2.0.18"
+uuid = { version = "1.23.1", features = ["v4", "v7", "serde"]}

+ 1 - 0
src/main.rs

@@ -7,6 +7,7 @@ use std::env;
 mod http_error;
 mod routes;
 mod controllers;
+mod models;
 
 #[actix_web::main]
 async fn main() -> std::io::Result<()> {

+ 1 - 0
src/models/mod.rs

@@ -0,0 +1 @@
+pub mod user;

+ 10 - 0
src/models/user.rs

@@ -0,0 +1,10 @@
+use uuid::Uuid;
+use chrono::{DateTime, Utc};
+
+pub struct User {
+    id: Uuid,
+    token: Uuid,
+    name: String,
+    pass_hash: String,
+    created_at: DateTime<Utc>
+}