style: cargo fmt --all

This commit is contained in:
2026-05-31 05:31:42 +02:00
parent 4b31a0f74b
commit c2ebca0da0
138 changed files with 2422 additions and 1164 deletions

View File

@@ -1,10 +1,14 @@
use axum::{extract::State, http::StatusCode, Json};
use crate::{
errors::AppError,
extractors::{JwtClaims, ValidatedJson},
state::AppState,
};
use api_types::{
requests::{LoginRequest, RegisterRequest},
responses::{AuthResponse, UserResponse},
};
use application::identity::{RegisterUserCommand, LoginUserCommand, GetProfileQuery};
use crate::{errors::AppError, extractors::{JwtClaims, ValidatedJson}, state::AppState};
use application::identity::{GetProfileQuery, LoginUserCommand, RegisterUserCommand};
use axum::{Json, extract::State, http::StatusCode};
#[utoipa::path(
post, path = "/api/v1/auth/register",
@@ -25,8 +29,18 @@ pub async fn register(
password: req.password,
};
let user = state.register_handler.execute(cmd).await?;
let token = state.token_issuer.issue(&user.id, "user").await.map_err(AppError::from)?;
Ok((StatusCode::CREATED, Json(AuthResponse { token, user: UserResponse::from_domain(&user) })))
let token = state
.token_issuer
.issue(&user.id, "user")
.await
.map_err(AppError::from)?;
Ok((
StatusCode::CREATED,
Json(AuthResponse {
token,
user: UserResponse::from_domain(&user),
}),
))
}
#[utoipa::path(
@@ -46,7 +60,10 @@ pub async fn login(
password: req.password,
};
let (user, token) = state.login_handler.execute(cmd).await?;
Ok(Json(AuthResponse { token, user: UserResponse::from_domain(&user) }))
Ok(Json(AuthResponse {
token,
user: UserResponse::from_domain(&user),
}))
}
#[utoipa::path(
@@ -61,7 +78,9 @@ pub async fn me(
State(state): State<AppState>,
claims: JwtClaims,
) -> Result<Json<UserResponse>, AppError> {
let query = GetProfileQuery { user_id: claims.user_id };
let query = GetProfileQuery {
user_id: claims.user_id,
};
let user = state.get_profile_handler.execute(query).await?;
Ok(Json(UserResponse::from_domain(&user)))
}