From 6280ef8efb819f3b842fba6a33880012172eddbe Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 15:02:22 -0400 Subject: [PATCH 1/5] tsk-179: Updating docs for endpoint status codes --- src/callers/queue/song.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 1dcf38d..40cc9a8 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -124,7 +124,9 @@ pub mod endpoint { content_type = "multipart/form-data" ), responses( - (status = 200, description = "Song queued", body = super::response::song_queue::Response) + (status = 200, description = "Song queued", body = super::response::song_queue::Response), + (status = 400, description = "Invalid request passed", body = super::response::song_queue::Response), + (status = 500, description = "Error queueing song", body = super::response::song_queue::Response) ) )] pub async fn queue_song( @@ -379,7 +381,8 @@ pub mod endpoint { responses( (status = 200, description = "Queued song updated", body = super::response::update_song_queue::Response), (status = 400, description = "Error updating queued song", body = super::response::update_song_queue::Response), - (status = 404, description = "Queued song not found", body = super::response::update_song_queue::Response) + (status = 404, description = "Queued song not found", body = super::response::update_song_queue::Response), + (status = 500, description = "Error updating queued song", body = super::response::update_song_queue::Response) ) )] pub async fn update_song_queue( -- 2.47.3 From 087e214eed60081c09327f2077c47c8ec0dd4837 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 15:03:21 -0400 Subject: [PATCH 2/5] tsk-179: Updated status code --- src/callers/queue/song.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 40cc9a8..7d39246 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -124,7 +124,7 @@ pub mod endpoint { content_type = "multipart/form-data" ), responses( - (status = 200, description = "Song queued", body = super::response::song_queue::Response), + (status = 201, description = "Song queued", body = super::response::song_queue::Response), (status = 400, description = "Invalid request passed", body = super::response::song_queue::Response), (status = 500, description = "Error queueing song", body = super::response::song_queue::Response) ) @@ -188,7 +188,7 @@ pub mod endpoint { String::from(super::super::super::response::SUCCESSFUL) }; - (axum::http::StatusCode::OK, axum::Json(response)) + (axum::http::StatusCode::CREATED, axum::Json(response)) } /// Endpoint to link a user id to a queued song -- 2.47.3 From 72ea822f578b8799f18c0540bcd31f3af447d609 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 15:06:03 -0400 Subject: [PATCH 3/5] tsk-179: Improved error handling --- src/callers/queue/song.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 7d39246..bbdac0f 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -157,15 +157,22 @@ pub mod endpoint { match super::is_song_valid(&raw_data).await { Ok(valid) => { if valid { - let queue_repo = repo::song::insert( + match repo::song::insert( &pool, &raw_data, &file_name, &crate::repo::queue::song::status::PENDING.to_string(), ) - .await - .unwrap(); - results.push(queue_repo); + .await { + Ok(queued_song) => { + results.push(queued_song); + } + Err(err) => { + response.message = err.to_string(); + return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, + axum::Json(response)); + } + } } else { response.message = String::from("Invalid song type"); return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)); -- 2.47.3 From d868b60a3014f201fe2042fb6efeeedb7f735f91 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 15:06:37 -0400 Subject: [PATCH 4/5] tsk-179: Code formatting --- src/callers/queue/song.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index bbdac0f..bb280f9 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -163,14 +163,17 @@ pub mod endpoint { &file_name, &crate::repo::queue::song::status::PENDING.to_string(), ) - .await { + .await + { Ok(queued_song) => { results.push(queued_song); } Err(err) => { response.message = err.to_string(); - return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, - axum::Json(response)); + return ( + axum::http::StatusCode::INTERNAL_SERVER_ERROR, + axum::Json(response), + ); } } } else { -- 2.47.3 From b656bdb97383b6536d5380221ae5511353520d16 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 15:06:47 -0400 Subject: [PATCH 5/5] tsk-179: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee7173a..426ba54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,7 +834,7 @@ dependencies = [ [[package]] name = "icarus" -version = "0.3.10" +version = "0.3.11" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index 55321cd..d81ea78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus" -version = "0.3.10" +version = "0.3.11" edition = "2024" rust-version = "1.90" -- 2.47.3