use crate::{errors::AppError, extractors::JwtClaims, state::AppState}; use api_types::{ requests::{RegisterLibraryPathRequest, RegisterVolumeRequest}, responses::{LibraryPathResponse, VolumeResponse}, }; use application::storage::{RegisterLibraryPathCommand, RegisterVolumeCommand}; use axum::{Json, extract::State, http::StatusCode}; use domain::value_objects::SystemId; pub async fn register_volume( State(state): State, _claims: JwtClaims, Json(req): Json, ) -> Result<(StatusCode, Json), AppError> { let cmd = RegisterVolumeCommand { volume_name: req.volume_name, uri_prefix: req.uri_prefix, is_writable: req.is_writable, }; let volume = state.register_volume_handler.execute(cmd).await?; Ok((StatusCode::CREATED, Json(VolumeResponse::from_domain(&volume)))) } pub async fn register_library_path( State(state): State, _claims: JwtClaims, Json(req): Json, ) -> Result<(StatusCode, Json), AppError> { let cmd = RegisterLibraryPathCommand { volume_id: SystemId::from_uuid(req.volume_id), relative_path: req.relative_path, owner_id: SystemId::from_uuid(req.owner_id), 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)))) }