refactor: clean up presentation layer — AppState grouping, multipart extractor, thin handlers
This commit is contained in:
@@ -1,70 +1,47 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use application::{
|
||||
catalog::{GetAssetHandler, GetTimelineHandler, UpdateMetadataHandler},
|
||||
catalog::{GetAssetHandler, GetTimelineHandler, ReadAssetFileHandler, UpdateMetadataHandler},
|
||||
identity::{GetProfileHandler, LoginUserHandler, RegisterUserHandler},
|
||||
organization::{CreateAlbumHandler, GetAlbumHandler, ManageAlbumEntriesHandler},
|
||||
storage::{IngestAssetHandler, RegisterLibraryPathHandler, RegisterVolumeHandler},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use domain::ports::TokenIssuer;
|
||||
|
||||
use domain::ports::{AssetRepository, FileStoragePort, StoragePort, TokenIssuer};
|
||||
#[derive(Clone)]
|
||||
pub struct IdentityHandlers {
|
||||
pub register: Arc<RegisterUserHandler>,
|
||||
pub login: Arc<LoginUserHandler>,
|
||||
pub get_profile: Arc<GetProfileHandler>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CatalogHandlers {
|
||||
pub ingest_asset: Arc<IngestAssetHandler>,
|
||||
pub get_asset: Arc<GetAssetHandler>,
|
||||
pub get_timeline: Arc<GetTimelineHandler>,
|
||||
pub update_metadata: Arc<UpdateMetadataHandler>,
|
||||
pub read_asset_file: Arc<ReadAssetFileHandler>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct OrganizationHandlers {
|
||||
pub create_album: Arc<CreateAlbumHandler>,
|
||||
pub get_album: Arc<GetAlbumHandler>,
|
||||
pub manage_album_entries: Arc<ManageAlbumEntriesHandler>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct StorageHandlers {
|
||||
pub register_volume: Arc<RegisterVolumeHandler>,
|
||||
pub register_library_path: Arc<RegisterLibraryPathHandler>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub register_handler: Arc<RegisterUserHandler>,
|
||||
pub login_handler: Arc<LoginUserHandler>,
|
||||
pub get_profile_handler: Arc<GetProfileHandler>,
|
||||
pub identity: IdentityHandlers,
|
||||
pub catalog: CatalogHandlers,
|
||||
pub organization: OrganizationHandlers,
|
||||
pub storage: StorageHandlers,
|
||||
pub token_issuer: Arc<dyn TokenIssuer>,
|
||||
pub storage: Arc<dyn StoragePort>,
|
||||
pub create_album_handler: Arc<CreateAlbumHandler>,
|
||||
pub get_album_handler: Arc<GetAlbumHandler>,
|
||||
pub manage_album_entries_handler: Arc<ManageAlbumEntriesHandler>,
|
||||
pub ingest_asset_handler: Arc<IngestAssetHandler>,
|
||||
pub get_asset_handler: Arc<GetAssetHandler>,
|
||||
pub get_timeline_handler: Arc<GetTimelineHandler>,
|
||||
pub update_metadata_handler: Arc<UpdateMetadataHandler>,
|
||||
pub register_volume_handler: Arc<RegisterVolumeHandler>,
|
||||
pub register_library_path_handler: Arc<RegisterLibraryPathHandler>,
|
||||
pub file_storage: Arc<dyn FileStoragePort>,
|
||||
pub asset_repo: Arc<dyn AssetRepository>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
register_handler: Arc<RegisterUserHandler>,
|
||||
login_handler: Arc<LoginUserHandler>,
|
||||
get_profile_handler: Arc<GetProfileHandler>,
|
||||
token_issuer: Arc<dyn TokenIssuer>,
|
||||
storage: Arc<dyn StoragePort>,
|
||||
create_album_handler: Arc<CreateAlbumHandler>,
|
||||
get_album_handler: Arc<GetAlbumHandler>,
|
||||
manage_album_entries_handler: Arc<ManageAlbumEntriesHandler>,
|
||||
ingest_asset_handler: Arc<IngestAssetHandler>,
|
||||
get_asset_handler: Arc<GetAssetHandler>,
|
||||
get_timeline_handler: Arc<GetTimelineHandler>,
|
||||
update_metadata_handler: Arc<UpdateMetadataHandler>,
|
||||
register_volume_handler: Arc<RegisterVolumeHandler>,
|
||||
register_library_path_handler: Arc<RegisterLibraryPathHandler>,
|
||||
file_storage: Arc<dyn FileStoragePort>,
|
||||
asset_repo: Arc<dyn AssetRepository>,
|
||||
) -> Self {
|
||||
Self {
|
||||
register_handler,
|
||||
login_handler,
|
||||
get_profile_handler,
|
||||
token_issuer,
|
||||
storage,
|
||||
create_album_handler,
|
||||
get_album_handler,
|
||||
manage_album_entries_handler,
|
||||
ingest_asset_handler,
|
||||
get_asset_handler,
|
||||
get_timeline_handler,
|
||||
update_metadata_handler,
|
||||
register_volume_handler,
|
||||
register_library_path_handler,
|
||||
file_storage,
|
||||
asset_repo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user