feat(application, api-types): use cases with tests and DTOs

This commit is contained in:
2026-05-17 23:58:02 +02:00
parent ed5e238a9c
commit 531b8f6eae
11 changed files with 337 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
[package]
name = "api-types"
version = "0.1.0"
edition = "2024"
[dependencies]
domain = { workspace = true }
serde = { workspace = true }
uuid = { workspace = true }
chrono = { workspace = true }
utoipa = { workspace = true }

View File

@@ -0,0 +1,2 @@
pub mod requests;
pub mod responses;

View 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,
}

View 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,
}
}
}