diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 78f0b28..82de0ff 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -33,14 +33,12 @@ pub mod response { } } - pub mod endpoint { use axum::response::IntoResponse; use crate::repo; use crate::repo::queue as repo_queue; - /// Endpoint to create cover art #[utoipa::path( post, @@ -122,7 +120,6 @@ pub mod endpoint { } } - /// Endpoint to get cover art with criteria #[utoipa::path( get, diff --git a/src/callers/queue/coverart.rs b/src/callers/queue/coverart.rs index 3166afc..16ed258 100644 --- a/src/callers/queue/coverart.rs +++ b/src/callers/queue/coverart.rs @@ -51,7 +51,6 @@ pub mod request { } } - pub mod response { pub mod queue { #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] @@ -100,7 +99,6 @@ pub mod response { } } - mod helper { pub fn is_coverart_file_type_valid(file_type: &String) -> bool { let valid_file_types = vec![ @@ -119,13 +117,11 @@ mod helper { } } - pub mod endpoint { use axum::response::IntoResponse; use crate::repo::queue as repo; - /// Endpoint to queue cover art #[utoipa::path( post, @@ -183,8 +179,7 @@ pub mod endpoint { file_type ); - match repo::coverart::insert(&pool, &raw_data, &file_type.file_type).await - { + match repo::coverart::insert(&pool, &raw_data, &file_type.file_type).await { Ok(id) => { response.message = String::from("Successful"); response.data.push(id); @@ -283,24 +278,22 @@ pub mod endpoint { } }, _ => match params.song_queue_id { - Some(song_queue_id) => { - match repo::coverart::get_coverart_queue_with_song_queue_id( - &pool, - &song_queue_id, - ) - .await - { - Ok(cover_art_queue) => { - response.message = String::from("Successful"); - response.data.push(cover_art_queue); - (axum::http::StatusCode::OK, axum::Json(response)) - } - Err(err) => { - response.message = err.to_string(); - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) - } + Some(song_queue_id) => match repo::coverart::get_coverart_queue_with_song_queue_id( + &pool, + &song_queue_id, + ) + .await + { + Ok(cover_art_queue) => { + response.message = String::from("Successful"); + response.data.push(cover_art_queue); + (axum::http::StatusCode::OK, axum::Json(response)) } - } + Err(err) => { + response.message = err.to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + }, None => { response.message = String::from("No valid id provided"); (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) diff --git a/src/callers/queue/mod.rs b/src/callers/queue/mod.rs index f76a2ee..165fc86 100644 --- a/src/callers/queue/mod.rs +++ b/src/callers/queue/mod.rs @@ -1,2 +1 @@ pub mod coverart; - diff --git a/src/main.rs b/src/main.rs index 412ab9f..b011398 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,12 +58,12 @@ pub mod init { use crate::callers::song as song_caller; use coverart_caller::endpoint as coverart_endpoints; use coverart_caller::response as coverart_responses; + use coverart_queue_callers::endpoint as coverart_queue_endpoints; + use coverart_queue_callers::response as coverart_queue_responses; use metadata_caller::endpoint as metadata_endpoints; use metadata_caller::response as metadata_responses; use song_caller::endpoint as song_endpoints; use song_caller::response as song_responses; - use coverart_queue_callers::endpoint as coverart_queue_endpoints; - use coverart_queue_callers::response as coverart_queue_responses; mod cors { pub async fn configure_cors() -> tower_http::cors::CorsLayer { @@ -199,9 +199,10 @@ pub mod init { ) .route( crate::callers::endpoints::QUEUECOVERARTDATA, - get(crate::callers::queue::coverart::endpoint::fetch_coverart_with_data).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), + get(crate::callers::queue::coverart::endpoint::fetch_coverart_with_data) + .route_layer(axum::middleware::from_fn( + crate::auth::auth::, + )), ) .route( crate::callers::endpoints::QUEUECOVERART,