diff --git a/Cargo.lock b/Cargo.lock index 03a6b5b..8be6ce7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,7 +234,10 @@ checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", + "serde", + "wasm-bindgen", "windows-targets 0.52.6", ] @@ -1600,6 +1603,7 @@ version = "0.1.0" dependencies = [ "argon2", "atom_syndication", + "chrono", "rocket", "rocket_dyn_templates", "rss", diff --git a/Cargo.toml b/Cargo.toml index ce29cee..33581b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] argon2 = "0.5.3" atom_syndication = "0.12.6" +chrono = { version = "0.4.34", features = ["serde"] } rocket = { version = "0.5.1", features = ["json"] } rocket_dyn_templates = { version = "0.2.0", features = ["tera"] } rss = "2.0.11" diff --git a/src/main.rs b/src/main.rs index 610d31b..c159c25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use rocket::serde::{Serialize, json::Json}; use rocket_dyn_templates::{Template, context}; use rocket::fs::FileServer; +use uuid::Uuid; #[derive(Serialize)] #[serde(crate = "rocket::serde")] @@ -11,6 +12,28 @@ struct Message { b: String, } +#[derive(Debug, Serialize)] +#[serde(crate = "rocket::serde")] +struct User { + id: Uuid, + username: String, + email: Option, + display_name: Option, + created_at: String, // ISO 8601 formatted date string +} + +impl User { + fn new(username: String, email: Option, display_name: Option) -> Self { + User { + id: Uuid::new_v4(), + username, + email, + display_name, + created_at: chrono::Utc::now().to_rfc3339(), + } + } +} + #[get("/message")] fn message() -> Json { Json(Message {