From dd04c79d7d3768b7607fd739e44785b90b5aeb13 Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 6 Nov 2026 16:33:27 -0500 Subject: [PATCH 1/5] tsk-268: Updated readme --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9261adc..c47948f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,11 @@ Copy the `.env.docker.sample` file to `.env`. Ensure that the `ROOT_DIRECTORY` v and exists on the docker image's filesystem. The credentials for the database doesn't need to be changed for development, but if deploying it, it should be modified. +### Authentication setup +Make sure the `SECRET_MAIN_KEY` variable in the `.env` file is at least **24** characters long +and it should match the same value as the `SECRET_KEY` variable from `soaricarus_auth`. + + ### S3 Setup Using the copied `.env.docker.sample`, ensure that the following has been properly populated. ``` @@ -41,7 +46,7 @@ docker compose build --ssh default Bring it up ``` -docker compose up -d --force-recreate +docker compose up ``` To view the OpenAPI spec, run the project and access `/swagger-ui`. If running through docker, -- 2.47.3 From 0f15c141c6373a3225266f0e96b38e8cad4c941a Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 6 Nov 2026 16:33:41 -0500 Subject: [PATCH 2/5] bump: soaricarus_api --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4a9744..db0dbd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3190,7 +3190,7 @@ dependencies = [ [[package]] name = "soaricarus_api" -version = "0.5.11" +version = "0.5.12" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index c4ae368..623913a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soaricarus_api" -version = "0.5.11" +version = "0.5.12" edition = "2024" rust-version = "1.95" license = "MIT" -- 2.47.3 From 3e1bd59aa35d683d8bc120ba05d61484a6ca8d0f Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 6 Nov 2026 16:34:45 -0500 Subject: [PATCH 3/5] tsk-268: Extending functionality --- src/callers/coverart.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index d4f590d..16e37b7 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -11,6 +11,7 @@ pub mod request { #[derive(Debug, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct Params { pub id: Option, + pub song_id: Option, } } } @@ -181,7 +182,8 @@ pub mod endpoint { get, path = super::super::endpoints::GETCOVERART, params( - ("id" = uuid::Uuid, Path, description = "Cover art Id") + ("id" = uuid::Uuid, Path, description = "Cover art Id"), + ("song_id" = uuid::Uuid, Path, description = "Song Id") ), responses( (status = 200, description = "Cover art retrieved", body = super::response::get_coverart::Response), @@ -201,7 +203,7 @@ pub mod endpoint { Some(id) => match repo::coverart::get_coverart(&pool, &id).await { Ok(coverart) => { response.data.push(coverart); - response.message = String::from(super::super::response::SUCCESSFUL); + response.message = super::super::response::SUCCESSFUL.to_string(); (axum::http::StatusCode::OK, axum::Json(response)) } Err(err) => { @@ -209,10 +211,28 @@ pub mod endpoint { (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) } }, - None => { - response.message = String::from("Invalid parameters"); - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) - } + _ => match params.song_id { + Some(song_id) => { + match repo::coverart::get_coverart_with_song_id(&pool, &song_id).await { + Ok(coverart) => { + response.data.push(coverart); + response.message = super::super::response::SUCCESSFUL.to_string(); + (axum::http::StatusCode::OK, axum::Json(response)) + } + Err(err) => { + response.message = err.to_string(); + ( + axum::http::StatusCode::INTERNAL_SERVER_ERROR, + axum::Json(response), + ) + } + } + } + None => { + response.message = "Invalid parameters".to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + }, } } -- 2.47.3 From 53c2cd8d41ebe91623d04bca5465d80a4a988d5c Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 6 Nov 2026 16:51:30 -0500 Subject: [PATCH 4/5] tsk-268: Added test --- src/main.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/main.rs b/src/main.rs index a9a9f4d..1f55cd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2143,6 +2143,59 @@ mod tests { let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await; } + #[tokio::test] + async fn test_get_coverart_with_song_id() { + let tm_pool = super::db_mgr::get_pool().await.unwrap(); + let db_name = super::db_mgr::generate_db_name().await; + + match super::db_mgr::create_database(&tm_pool, &db_name).await { + Ok(_) => { + println!("Success"); + } + Err(err) => { + assert!(false, "Error: {:?}", err); + } + } + + let pool = super::db_mgr::connect_to_db(&db_name).await.unwrap(); + super::db_mgr::migrations(&pool).await; + + let app = super::init::app(pool).await; + + let (song_id, _, _, _) = test_data::song_id().await.unwrap(); + + let uri = format!( + "{}?song_id={song_id}", + soaricarus_api::callers::endpoints::GETCOVERART + ); + + match app + .clone() + .oneshot( + super::request::run_post(None, &uri, axum::http::Method::GET, false) + .await + .unwrap(), + ) + .await + { + Ok(response) => { + let resp = super::util::get_resp_data::< + soaricarus_api::callers::coverart::response::get_coverart::Response, + >(response) + .await; + assert_eq!(false, resp.data.is_empty(), "Should not be empty"); + + let coverart = resp.data[0].clone(); + assert_eq!(song_id, coverart.song_id, "Song Id does not match {coverart:?}"); + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + + let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await; + } + pub mod test_data { pub async fn song_id() -> Result<(uuid::Uuid, String, String, String), uuid::Error> { match uuid::Uuid::parse_str("44cf7940-34ff-489f-9124-d0ec90a55af9") { -- 2.47.3 From e8a7bdd7946d80f3675e8d808d3c19b30b078896 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 7 Nov 2026 10:55:20 -0500 Subject: [PATCH 5/5] tsk-268: formatting --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1f55cd0..88485ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2186,7 +2186,10 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Should not be empty"); let coverart = resp.data[0].clone(); - assert_eq!(song_id, coverart.song_id, "Song Id does not match {coverart:?}"); + assert_eq!( + song_id, coverart.song_id, + "Song Id does not match {coverart:?}" + ); } Err(err) => { assert!(false, "Error: {err:?}"); -- 2.47.3