refactor: migrate to clean architecture with trait-based DI (v0.2.0)
Complete architectural overhaul across all 12 crates: - Replace validator crate with zod-rs for all DTO validation - Replace manual pagination with paginator-rs/paginator-sea-orm - Migrate all modules (iam, cms, gacha, dimentorin) to clean architecture: domain → application → infrastructure layers - Introduce trait-based DI (Arc<dyn Trait>) at every layer for repositories and services - Delete all v1/ legacy SurrealDB-era code across every crate - Replace opaque response helpers with typed IntoResponse structs (ApiSuccess, ApiCreated, ApiPaginated, ApiMessage) - Remove dual_mode_repository, migration_validation_errors, validator.rs dead code - Zero cargo clippy warnings; release build clean Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1b3366d735
commit
e432a1a743
@@ -0,0 +1,29 @@
|
||||
use std::sync::Arc;
|
||||
use axum::{Router, routing::post, Extension};
|
||||
use sea_orm::DatabaseConnection;
|
||||
use imphnen_libs::AppState;
|
||||
use crate::auth::domain::AuthService;
|
||||
use crate::auth::application::AuthServiceImpl;
|
||||
use crate::users::infrastructure::persistence::PostgresUserRepository;
|
||||
use crate::roles::infrastructure::persistence::PostgresRoleRepository;
|
||||
use super::handlers::{
|
||||
post_login, post_login_mentor, post_register, post_verify_email,
|
||||
post_resend_otp, post_forgot_password, post_new_password, post_refresh_token,
|
||||
};
|
||||
|
||||
pub fn auth_public_routes(_db: DatabaseConnection, state: Arc<AppState>) -> Router {
|
||||
let user_repo = Arc::new(PostgresUserRepository::new(state.postgres_connection.conn.clone()));
|
||||
let role_repo = Arc::new(PostgresRoleRepository::new(state.postgres_connection.conn.clone()));
|
||||
let auth_service: Arc<dyn AuthService> = Arc::new(AuthServiceImpl::new(user_repo, role_repo));
|
||||
Router::new()
|
||||
.route("/auth/login", post(post_login))
|
||||
.route("/auth/login-mentor", post(post_login_mentor))
|
||||
.route("/auth/register", post(post_register))
|
||||
.route("/auth/verify-email", post(post_verify_email))
|
||||
.route("/auth/send-otp", post(post_resend_otp))
|
||||
.route("/auth/forgot", post(post_forgot_password))
|
||||
.route("/auth/new-password", post(post_new_password))
|
||||
.route("/auth/refresh", post(post_refresh_token))
|
||||
.layer(Extension(auth_service))
|
||||
.layer(Extension((*state).clone()))
|
||||
}
|
||||
Reference in New Issue
Block a user