tsk-245: Modify result when getting songs but no songs are present #247

Merged
kdeng00 merged 3 commits from tsk-245 into main 2025-11-07 11:48:07 -05:00
3 changed files with 10 additions and 5 deletions
Generated
+1 -1
View File
@@ -964,7 +964,7 @@ dependencies = [
[[package]] [[package]]
name = "icarus" name = "icarus"
version = "0.3.27" version = "0.3.28"
dependencies = [ dependencies = [
"axum", "axum",
"axum-extra", "axum-extra",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "icarus" name = "icarus"
version = "0.3.27" version = "0.3.28"
edition = "2024" edition = "2024"
rust-version = "1.90" rust-version = "1.90"
+5
View File
@@ -251,10 +251,15 @@ pub mod endpoint {
match repo::song::get_all_songs(&pool).await { match repo::song::get_all_songs(&pool).await {
Ok(songs) => { Ok(songs) => {
if songs.is_empty() {
response.message = String::from("No songs available");
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
} else {
response.message = String::from(super::super::response::SUCCESSFUL); response.message = String::from(super::super::response::SUCCESSFUL);
response.data = songs; response.data = songs;
(axum::http::StatusCode::OK, axum::Json(response)) (axum::http::StatusCode::OK, axum::Json(response))
} }
}
Err(err) => { Err(err) => {
response.message = err.to_string(); response.message = err.to_string();
(axum::http::StatusCode::NOT_FOUND, axum::Json(response)) (axum::http::StatusCode::NOT_FOUND, axum::Json(response))