feat: vertical slice — migrations, postgres adapters, presentation handlers, bootstrap wiring

This commit is contained in:
2026-05-31 05:52:42 +02:00
parent 201eff717d
commit 9aba393fde
11 changed files with 70 additions and 55 deletions

View File

@@ -23,7 +23,10 @@ pub async fn create_album(
creator_id: claims.user_id,
};
let album = state.create_album_handler.execute(cmd).await?;
Ok((StatusCode::CREATED, Json(AlbumResponse::from_domain(&album))))
Ok((
StatusCode::CREATED,
Json(AlbumResponse::from_domain(&album)),
))
}
pub async fn get_album(

View File

@@ -40,43 +40,43 @@ pub async fn ingest(
match name.as_str() {
"file" => {
filename = field.file_name().map(|s| s.to_string());
let data = field
.bytes()
.await
.map_err(|e| {
AppError::from(domain::errors::DomainError::Internal(e.to_string()))
})?;
let data = field.bytes().await.map_err(|e| {
AppError::from(domain::errors::DomainError::Internal(e.to_string()))
})?;
file_data = Some(data);
}
"target_path_id" => {
let text = field
.text()
.await
.map_err(|e| {
AppError::from(domain::errors::DomainError::Validation(e.to_string()))
})?;
let text = field.text().await.map_err(|e| {
AppError::from(domain::errors::DomainError::Validation(e.to_string()))
})?;
target_path_id = Some(text.parse::<uuid::Uuid>().map_err(|e| {
AppError::from(domain::errors::DomainError::Validation(e.to_string()))
})?);
}
"client_device_id" => {
client_device_id = field
.text()
.await
.map_err(|e| {
AppError::from(domain::errors::DomainError::Validation(e.to_string()))
})?;
client_device_id = field.text().await.map_err(|e| {
AppError::from(domain::errors::DomainError::Validation(e.to_string()))
})?;
}
_ => {}
}
}
let data = file_data
.ok_or_else(|| AppError::from(domain::errors::DomainError::Validation("Missing file field".to_string())))?;
let fname = filename
.ok_or_else(|| AppError::from(domain::errors::DomainError::Validation("Missing filename".to_string())))?;
let path_id = target_path_id
.ok_or_else(|| AppError::from(domain::errors::DomainError::Validation("Missing target_path_id".to_string())))?;
let data = file_data.ok_or_else(|| {
AppError::from(domain::errors::DomainError::Validation(
"Missing file field".to_string(),
))
})?;
let fname = filename.ok_or_else(|| {
AppError::from(domain::errors::DomainError::Validation(
"Missing filename".to_string(),
))
})?;
let path_id = target_path_id.ok_or_else(|| {
AppError::from(domain::errors::DomainError::Validation(
"Missing target_path_id".to_string(),
))
})?;
let mut hasher = Sha256::new();
hasher.update(&data);

View File

@@ -18,7 +18,10 @@ pub async fn register_volume(
is_writable: req.is_writable,
};
let volume = state.register_volume_handler.execute(cmd).await?;
Ok((StatusCode::CREATED, Json(VolumeResponse::from_domain(&volume))))
Ok((
StatusCode::CREATED,
Json(VolumeResponse::from_domain(&volume)),
))
}
pub async fn register_library_path(
@@ -33,5 +36,8 @@ pub async fn register_library_path(
is_ingest_destination: req.is_ingest_destination,
};
let path = state.register_library_path_handler.execute(cmd).await?;
Ok((StatusCode::CREATED, Json(LibraryPathResponse::from_domain(&path))))
Ok((
StatusCode::CREATED,
Json(LibraryPathResponse::from_domain(&path)),
))
}

View File

@@ -18,7 +18,10 @@ pub fn api_v1_router() -> Router<AppState> {
.route("/albums", post(albums::create_album))
.route("/albums/:id", get(albums::get_album))
.route("/albums/:id/entries", post(albums::add_entry))
.route("/albums/:id/entries/:asset_id", delete(albums::remove_entry))
.route(
"/albums/:id/entries/:asset_id",
delete(albums::remove_entry),
)
// assets
.route("/assets/ingest", post(assets::ingest))
.route("/assets/timeline", get(assets::timeline))
@@ -26,7 +29,10 @@ pub fn api_v1_router() -> Router<AppState> {
.route("/assets/:id/metadata", put(assets::update_metadata))
// storage
.route("/storage/volumes", post(storage::register_volume))
.route("/storage/library-paths", post(storage::register_library_path))
.route(
"/storage/library-paths",
post(storage::register_library_path),
)
}
pub fn app_router() -> Router<AppState> {