diff options
Diffstat (limited to 'src/model.rs')
-rw-r--r-- | src/model.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/model.rs b/src/model.rs new file mode 100644 index 0000000..9c1bfe6 --- /dev/null +++ b/src/model.rs @@ -0,0 +1,46 @@ +use chrono::prelude::*; +use serde::{Deserialize, Serialize}; + +#[allow(non_snake_case)] +#[derive(Debug, Deserialize, sqlx::FromRow, Serialize, Clone)] +pub struct User { + pub id: uuid::Uuid, + pub name: String, + pub email: String, + pub password: String, + #[serde(rename = "createdAt")] + pub created_at: Option<DateTime<Utc>>, + #[serde(rename = "updatedAt")] + pub updated_at: Option<DateTime<Utc>>, +} + +impl User { + pub fn into_query_response(self) -> axum::Json<serde_json::Value> { + axum::Json(serde_json::json!({ + "status": "success", + "data": serde_json::json!({ + "user": self + }) + })) + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct TokenClaims { + pub sub: String, + pub iat: usize, + pub exp: usize, +} + +#[derive(Debug, Deserialize)] +pub struct RegisterUserSchema { + pub name: String, + pub email: String, + pub password: String, +} + +#[derive(Debug, Deserialize)] +pub struct LoginUserSchema { + pub email: String, + pub password: String, +} |