init: scaffold from k-template with postgres + worker
This commit is contained in:
2
crates/api-types/src/lib.rs
Normal file
2
crates/api-types/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod requests;
|
||||
pub mod responses;
|
||||
11
crates/api-types/src/requests.rs
Normal file
11
crates/api-types/src/requests.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
|
||||
pub struct RegisterRequest {
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
|
||||
pub struct LoginRequest {
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
}
|
||||
27
crates/api-types/src/responses.rs
Normal file
27
crates/api-types/src/responses.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
|
||||
pub struct UserResponse {
|
||||
pub id: Uuid,
|
||||
pub email: String,
|
||||
pub role: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
|
||||
pub struct AuthResponse {
|
||||
pub token: String,
|
||||
pub user: UserResponse,
|
||||
}
|
||||
|
||||
impl UserResponse {
|
||||
pub fn from_domain(user: &domain::entities::User) -> Self {
|
||||
Self {
|
||||
id: *user.id.as_uuid(),
|
||||
email: user.email.to_string(),
|
||||
role: user.role.to_string(),
|
||||
created_at: user.created_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user