Files
imphnen-backend-service/imphnen-libs/src/lib.rs
T
maulanasdqnandClaude Sonnet 4.6 e432a1a743 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>
2026-04-02 13:39:52 +07:00

69 lines
2.0 KiB
Rust

use std::sync::Arc;
pub mod postgres;
pub mod argon;
pub mod axum;
pub mod environment;
pub mod jsonwebtoken;
pub mod lettre;
pub mod minio;
pub mod services;
pub use argon::{hash_password, verify_password};
pub use axum::{axum_init, ValidatedJson, ZodValidate};
pub use environment::{ENV, Env};
pub use imphnen_entities::{
MessageResponseDto,
ResponseSuccessDto,
ResponseListSuccessDto,
UsersDetailQueryDto,
PermissionsEnum,
PermissionsItemDto,
PermissionsQueryDto,
};
pub use jsonwebtoken::{
Claims, encode_access_token, encode_refresh_token, decode_access_token,
decode_refresh_token, encode_reset_password_token, generate_jwt
};
pub use lettre::send_email;
pub use minio::{
MinioConfig, MinioService, UploadResult, FileType, UploadRequest, FileMetadata,
create_minio_service_from_config, decode_base64_file, extract_content_type_from_data_url
};
pub use services::{UserLookupService, AuthRepositoryTrait};
// Re-export concrete Postgres service implementations for convenience
pub use services::PostgresUserLookupService;
pub use services::PostgresAuthRepository;
pub use postgres::{
PostgresConnection, PostgresConfig, PostgresError, AppStatePostgresExt,
};
#[derive(Clone)]
pub struct AppState {
pub postgres_connection: Arc<PostgresConnection>,
pub user_lookup_service: Arc<dyn UserLookupService>,
pub auth_repository: Arc<dyn AuthRepositoryTrait>,
}
impl AppState {
/// Create a new AppState with PostgreSQL connection
pub async fn new(
postgres_config: PostgresConfig,
user_lookup_service: Arc<dyn UserLookupService>,
auth_repository: Arc<dyn AuthRepositoryTrait>,
) -> Result<Self, PostgresError> {
let postgres_connection = PostgresConnection::new(postgres_config).await?;
Ok(Self {
postgres_connection: Arc::new(postgres_connection),
user_lookup_service,
auth_repository,
})
}
}
impl AppStatePostgresExt for AppState {
fn postgres_connection(&self) -> &PostgresConnection {
&self.postgres_connection
}
}