From dc3977a2ea9c751e6532f84771da93cb4c20b244 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 4 Nov 2025 10:54:39 -0500 Subject: [PATCH 1/6] tsk-207: Move code elsewhere that is found in src/main.rs --- src/config/init.rs | 256 ++++++++++++++++++++++++++++++++++++++++++++ src/config/mod.rs | 1 + src/main.rs | 261 +-------------------------------------------- 3 files changed, 258 insertions(+), 260 deletions(-) create mode 100644 src/config/init.rs diff --git a/src/config/init.rs b/src/config/init.rs new file mode 100644 index 0000000..6505280 --- /dev/null +++ b/src/config/init.rs @@ -0,0 +1,256 @@ +use std::time::Duration; + +use axum::routing::{delete, get, patch, post}; +use tower_http::timeout::TimeoutLayer; +use utoipa::OpenApi; + +use crate::callers::coverart as coverart_caller; +use crate::callers::queue::coverart as coverart_queue_callers; +use crate::callers::queue::metadata as metadata_queue_caller; +use crate::callers::queue::song as song_queue_callers; +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_queue_caller::endpoint as metadata_queue_endpoints; +use metadata_queue_caller::response as metadata_queue_responses; +use song_caller::endpoint as song_endpoints; +use song_caller::response as song_responses; +use song_queue_callers::endpoint as song_queue_endpoints; +use song_queue_callers::response as song_queue_responses; + +mod cors { + pub async fn configure_cors() -> tower_http::cors::CorsLayer { + let cors = tower_http::cors::CorsLayer::new() + .allow_methods([ + axum::http::Method::GET, + axum::http::Method::POST, + axum::http::Method::PUT, + axum::http::Method::DELETE, + ]) // Specify allowed methods:cite[2] + .allow_headers([ + axum::http::header::CONTENT_TYPE, + axum::http::header::AUTHORIZATION, + ]) // Specify allowed headers:cite[2] + .allow_credentials(true) // If you need to send cookies or authentication headers:cite[2] + .max_age(std::time::Duration::from_secs(3600)); // Cache the preflight response for 1 hour:cite[2] + + // Dynamically set the allowed origin based on the environment + match std::env::var(icarus_envy::keys::APP_ENV).as_deref() { + Ok("production") => { + // In production, allow only your specific, trusted origins + let allowed_origins_env = icarus_envy::environment::get_allowed_origins().await; + match icarus_envy::utility::delimitize(&allowed_origins_env) { + Ok(alwd) => { + let allowed_origins: Vec = alwd + .into_iter() + .map(|a| a.parse::().unwrap()) + .collect(); + cors.allow_origin(allowed_origins) + } + Err(err) => { + eprintln!("Error getting allowed origins: Error: {err:?}"); + std::process::exit(-1); + } + } + } + _ => { + // Development (default): Allow localhost origins + cors.allow_origin(vec![ + "http://localhost:8000".parse().unwrap(), + "http://127.0.0.1:8000".parse().unwrap(), + "http://localhost:4200".parse().unwrap(), + "http://127.0.0.1:4200".parse().unwrap(), + ]) + } + } + } +} + +#[derive(utoipa::OpenApi)] +#[openapi( + paths(song_queue_endpoints::queue_song, song_queue_endpoints::link_user_id, song_queue_endpoints::fetch_queue_song, song_queue_endpoints::download_queued_song, + song_queue_endpoints::update_song_queue_status, song_queue_endpoints::update_song_queue, song_endpoints::create_metadata, song_queue_endpoints::wipe_data_from_song_queue, song_endpoints::get_songs, song_endpoints::get_all_songs, song_endpoints::stream_song, song_endpoints::download_song, + song_endpoints::delete_song, coverart_queue_endpoints::queue, coverart_queue_endpoints::link, coverart_queue_endpoints::fetch_coverart_no_data, + coverart_queue_endpoints::fetch_coverart_with_data, coverart_endpoints::create_coverart, coverart_queue_endpoints::wipe_data_from_coverart_queue, + coverart_endpoints::get_coverart, coverart_endpoints::download_coverart, + metadata_queue_endpoints::queue_metadata, metadata_queue_endpoints::fetch_metadata), + components(schemas(song_queue_callers::response::song_queue::Response, song_queue_callers::response::link_user_id::Response, song_queue_callers::response::fetch_queue_song::Response, + song_queue_responses::update_status::Response, song_queue_callers::response::update_song_queue::Response, song_responses::create_metadata::Response, + song_queue_callers::response::wipe_data_from_song_queue::Response, song_responses::get_songs::Response, song_responses::delete_song::Response, + coverart_queue_responses::queue::Response, coverart_queue_responses::link::Response, coverart_queue_responses::fetch_coverart_no_data::Response, + coverart_queue_responses::fetch_coverart_with_data::Response, coverart_responses::create_coverart::Response, + coverart_queue_responses::wipe_data_from_coverart_queue::Response, coverart_responses::get_coverart::Response, + metadata_queue_responses::queue_metadata::Response, metadata_queue_responses::fetch_metadata::Response)), + tags( + (name = "Icarus API", description = "Web API to manage music") + ) +)] +struct ApiDoc; + +pub async fn routes() -> axum::Router { + axum::Router::new() + .route(crate::callers::endpoints::ROOT, get(crate::callers::root)) + .route( + crate::callers::queue::endpoints::QUEUESONG, + post(crate::callers::queue::song::endpoint::queue_song).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUESONG, + patch(crate::callers::queue::song::endpoint::update_song_queue_status).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUESONGLINKUSERID, + patch(crate::callers::queue::song::endpoint::link_user_id).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUESONGDATA, + get(crate::callers::queue::song::endpoint::download_queued_song).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::NEXTQUEUESONG, + get(crate::callers::queue::song::endpoint::fetch_queue_song).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUESONGUPDATE, + patch(crate::callers::queue::song::endpoint::update_song_queue).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUESONGDATAWIPE, + patch(crate::callers::queue::song::endpoint::wipe_data_from_song_queue) + .route_layer(axum::middleware::from_fn( + crate::auth::auth::, + )), + ) + .route( + crate::callers::queue::endpoints::QUEUEMETADATA, + post(crate::callers::queue::metadata::endpoint::queue_metadata).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUEMETADATA, + get(crate::callers::queue::metadata::endpoint::fetch_metadata).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUECOVERART, + post(crate::callers::queue::coverart::endpoint::queue).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUECOVERARTDATA, + get(crate::callers::queue::coverart::endpoint::fetch_coverart_with_data) + .route_layer(axum::middleware::from_fn( + crate::auth::auth::, + )), + ) + .route( + crate::callers::queue::endpoints::QUEUECOVERART, + get(crate::callers::queue::coverart::endpoint::fetch_coverart_no_data).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUECOVERARTLINK, + patch(crate::callers::queue::coverart::endpoint::link).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE, + patch(crate::callers::queue::coverart::endpoint::wipe_data_from_coverart_queue) + .route_layer(axum::middleware::from_fn( + crate::auth::auth::, + )), + ) + .route( + crate::callers::endpoints::CREATESONG, + post(crate::callers::song::endpoint::create_metadata).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::CREATECOVERART, + post(crate::callers::coverart::endpoint::create_coverart).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::GETSONGS, + get(crate::callers::song::endpoint::get_songs).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::GETCOVERART, + get(crate::callers::coverart::endpoint::get_coverart).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::DOWNLOADCOVERART, + get(crate::callers::coverart::endpoint::download_coverart).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::STREAMSONG, + get(crate::callers::song::endpoint::stream_song).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::DOWNLOADSONG, + get(crate::callers::song::endpoint::download_song).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::DELETESONG, + delete(crate::callers::song::endpoint::delete_song).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), + ) + .route( + crate::callers::endpoints::GETALLSONGS, + get(crate::callers::song::endpoint::get_all_songs), + ) + .layer(cors::configure_cors().await) +} + +pub async fn app() -> axum::Router { + let pool = crate::db::create_pool() + .await + .expect("Failed to create pool"); + // TODO: Look into handling this. Seems redundant to run migrations multiple times + crate::db::migrations(&pool).await; + + let cors = cors::configure_cors().await; + + routes() + .await + .merge( + utoipa_swagger_ui::SwaggerUi::new("/swagger-ui") + .url("/api-docs/openapi.json", ApiDoc::openapi()), + ) + .layer(axum::Extension(pool)) + .layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024)) + .layer(TimeoutLayer::new(Duration::from_secs(300))) + .layer(cors) +} diff --git a/src/config/mod.rs b/src/config/mod.rs index 5361e40..2e93c42 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1 +1,2 @@ pub mod host; +pub mod init; diff --git a/src/main.rs b/src/main.rs index f6d0890..6048632 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ async fn main() { db::migrations(&pool).await; // build our application with a route - let app = init::app().await; + let app = config::init::app().await; let listener = tokio::net::TcpListener::bind(config::host::get_full()) .await @@ -48,265 +48,6 @@ async fn main() { axum::serve(listener, app).await.unwrap(); } -pub mod init { - use std::time::Duration; - - use axum::routing::{delete, get, patch, post}; - use tower_http::timeout::TimeoutLayer; - use utoipa::OpenApi; - - use crate::callers::coverart as coverart_caller; - use crate::callers::queue::coverart as coverart_queue_callers; - use crate::callers::queue::metadata as metadata_queue_caller; - use crate::callers::queue::song as song_queue_callers; - 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_queue_caller::endpoint as metadata_queue_endpoints; - use metadata_queue_caller::response as metadata_queue_responses; - use song_caller::endpoint as song_endpoints; - use song_caller::response as song_responses; - use song_queue_callers::endpoint as song_queue_endpoints; - use song_queue_callers::response as song_queue_responses; - - mod cors { - pub async fn configure_cors() -> tower_http::cors::CorsLayer { - let cors = tower_http::cors::CorsLayer::new() - .allow_methods([ - axum::http::Method::GET, - axum::http::Method::POST, - axum::http::Method::PUT, - axum::http::Method::DELETE, - ]) // Specify allowed methods:cite[2] - .allow_headers([ - axum::http::header::CONTENT_TYPE, - axum::http::header::AUTHORIZATION, - ]) // Specify allowed headers:cite[2] - .allow_credentials(true) // If you need to send cookies or authentication headers:cite[2] - .max_age(std::time::Duration::from_secs(3600)); // Cache the preflight response for 1 hour:cite[2] - - // Dynamically set the allowed origin based on the environment - match std::env::var(icarus_envy::keys::APP_ENV).as_deref() { - Ok("production") => { - // In production, allow only your specific, trusted origins - let allowed_origins_env = icarus_envy::environment::get_allowed_origins().await; - match icarus_envy::utility::delimitize(&allowed_origins_env) { - Ok(alwd) => { - let allowed_origins: Vec = alwd - .into_iter() - .map(|a| a.parse::().unwrap()) - .collect(); - cors.allow_origin(allowed_origins) - } - Err(err) => { - eprintln!("Error getting allowed origins: Error: {err:?}"); - std::process::exit(-1); - } - } - } - _ => { - // Development (default): Allow localhost origins - cors.allow_origin(vec![ - "http://localhost:8000".parse().unwrap(), - "http://127.0.0.1:8000".parse().unwrap(), - "http://localhost:4200".parse().unwrap(), - "http://127.0.0.1:4200".parse().unwrap(), - ]) - } - } - } - } - - #[derive(utoipa::OpenApi)] - #[openapi( - paths(song_queue_endpoints::queue_song, song_queue_endpoints::link_user_id, song_queue_endpoints::fetch_queue_song, song_queue_endpoints::download_queued_song, - song_queue_endpoints::update_song_queue_status, song_queue_endpoints::update_song_queue, song_endpoints::create_metadata, song_queue_endpoints::wipe_data_from_song_queue, song_endpoints::get_songs, song_endpoints::get_all_songs, song_endpoints::stream_song, song_endpoints::download_song, - song_endpoints::delete_song, coverart_queue_endpoints::queue, coverart_queue_endpoints::link, coverart_queue_endpoints::fetch_coverart_no_data, - coverart_queue_endpoints::fetch_coverart_with_data, coverart_endpoints::create_coverart, coverart_queue_endpoints::wipe_data_from_coverart_queue, - coverart_endpoints::get_coverart, coverart_endpoints::download_coverart, - metadata_queue_endpoints::queue_metadata, metadata_queue_endpoints::fetch_metadata), - components(schemas(song_queue_callers::response::song_queue::Response, song_queue_callers::response::link_user_id::Response, song_queue_callers::response::fetch_queue_song::Response, - song_queue_responses::update_status::Response, song_queue_callers::response::update_song_queue::Response, song_responses::create_metadata::Response, - song_queue_callers::response::wipe_data_from_song_queue::Response, song_responses::get_songs::Response, song_responses::delete_song::Response, - coverart_queue_responses::queue::Response, coverart_queue_responses::link::Response, coverart_queue_responses::fetch_coverart_no_data::Response, - coverart_queue_responses::fetch_coverart_with_data::Response, coverart_responses::create_coverart::Response, - coverart_queue_responses::wipe_data_from_coverart_queue::Response, coverart_responses::get_coverart::Response, - metadata_queue_responses::queue_metadata::Response, metadata_queue_responses::fetch_metadata::Response)), - tags( - (name = "Icarus API", description = "Web API to manage music") - ) - )] - struct ApiDoc; - - pub async fn routes() -> axum::Router { - axum::Router::new() - .route(crate::callers::endpoints::ROOT, get(crate::callers::root)) - .route( - crate::callers::queue::endpoints::QUEUESONG, - post(crate::callers::queue::song::endpoint::queue_song).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUESONG, - patch(crate::callers::queue::song::endpoint::update_song_queue_status).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUESONGLINKUSERID, - patch(crate::callers::queue::song::endpoint::link_user_id).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUESONGDATA, - get(crate::callers::queue::song::endpoint::download_queued_song).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::NEXTQUEUESONG, - get(crate::callers::queue::song::endpoint::fetch_queue_song).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUESONGUPDATE, - patch(crate::callers::queue::song::endpoint::update_song_queue).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUESONGDATAWIPE, - patch(crate::callers::queue::song::endpoint::wipe_data_from_song_queue) - .route_layer(axum::middleware::from_fn( - crate::auth::auth::, - )), - ) - .route( - crate::callers::queue::endpoints::QUEUEMETADATA, - post(crate::callers::queue::metadata::endpoint::queue_metadata).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUEMETADATA, - get(crate::callers::queue::metadata::endpoint::fetch_metadata).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUECOVERART, - post(crate::callers::queue::coverart::endpoint::queue).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUECOVERARTDATA, - get(crate::callers::queue::coverart::endpoint::fetch_coverart_with_data) - .route_layer(axum::middleware::from_fn( - crate::auth::auth::, - )), - ) - .route( - crate::callers::queue::endpoints::QUEUECOVERART, - get(crate::callers::queue::coverart::endpoint::fetch_coverart_no_data).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUECOVERARTLINK, - patch(crate::callers::queue::coverart::endpoint::link).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE, - patch(crate::callers::queue::coverart::endpoint::wipe_data_from_coverart_queue) - .route_layer(axum::middleware::from_fn( - crate::auth::auth::, - )), - ) - .route( - crate::callers::endpoints::CREATESONG, - post(crate::callers::song::endpoint::create_metadata).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::CREATECOVERART, - post(crate::callers::coverart::endpoint::create_coverart).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::GETSONGS, - get(crate::callers::song::endpoint::get_songs).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::GETCOVERART, - get(crate::callers::coverart::endpoint::get_coverart).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::DOWNLOADCOVERART, - get(crate::callers::coverart::endpoint::download_coverart).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::STREAMSONG, - get(crate::callers::song::endpoint::stream_song).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::DOWNLOADSONG, - get(crate::callers::song::endpoint::download_song).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::DELETESONG, - delete(crate::callers::song::endpoint::delete_song).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), - ) - .route( - crate::callers::endpoints::GETALLSONGS, - get(crate::callers::song::endpoint::get_all_songs), - ) - .layer(cors::configure_cors().await) - } - - pub async fn app() -> axum::Router { - let pool = crate::db::create_pool() - .await - .expect("Failed to create pool"); - // TODO: Look into handling this. Seems redundant to run migrations multiple times - crate::db::migrations(&pool).await; - - let cors = cors::configure_cors().await; - - routes() - .await - .merge( - utoipa_swagger_ui::SwaggerUi::new("/swagger-ui") - .url("/api-docs/openapi.json", ApiDoc::openapi()), - ) - .layer(axum::Extension(pool)) - .layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024)) - .layer(TimeoutLayer::new(Duration::from_secs(300))) - .layer(cors) - } -} - #[cfg(test)] mod tests { use std::io::Write; -- 2.47.3 From bf6dda45bb0bc6fbcf06374433ce7537567c5aee Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 4 Nov 2025 10:58:21 -0500 Subject: [PATCH 2/6] tsk-207: Some refactoring --- src/db/mod.rs | 24 ++++++++++++++++++++++++ src/main.rs | 28 +--------------------------- 2 files changed, 25 insertions(+), 27 deletions(-) create mode 100644 src/db/mod.rs diff --git a/src/db/mod.rs b/src/db/mod.rs new file mode 100644 index 0000000..41762ef --- /dev/null +++ b/src/db/mod.rs @@ -0,0 +1,24 @@ +use sqlx::postgres::PgPoolOptions; + +pub mod connection_settings { + pub const MAXCONN: u32 = 10; +} + +pub async fn create_pool() -> Result { + let database_url = icarus_envy::environment::get_db_url().await.value; + println!("Database url: {database_url}"); + + PgPoolOptions::new() + .max_connections(connection_settings::MAXCONN) + .connect(&database_url) + .await +} + +pub async fn migrations(pool: &sqlx::PgPool) { + // Run migrations using the sqlx::migrate! macro + // Assumes your migrations are in a ./migrations folder relative to Cargo.toml + sqlx::migrate!("./migrations") + .run(pool) + .await + .expect("Failed to run migrations"); +} diff --git a/src/main.rs b/src/main.rs index 6048632..d313d3d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,35 +1,9 @@ pub mod auth; +pub mod db; pub mod callers; pub mod config; pub mod repo; -pub mod db { - - use sqlx::postgres::PgPoolOptions; - - pub mod connection_settings { - pub const MAXCONN: u32 = 10; - } - - pub async fn create_pool() -> Result { - let database_url = icarus_envy::environment::get_db_url().await.value; - println!("Database url: {database_url}"); - - PgPoolOptions::new() - .max_connections(connection_settings::MAXCONN) - .connect(&database_url) - .await - } - - pub async fn migrations(pool: &sqlx::PgPool) { - // Run migrations using the sqlx::migrate! macro - // Assumes your migrations are in a ./migrations folder relative to Cargo.toml - sqlx::migrate!("./migrations") - .run(pool) - .await - .expect("Failed to run migrations"); - } -} #[tokio::main] async fn main() { -- 2.47.3 From 3e71ed31b8f91096e539c8dc2a3849e1384881ba Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 4 Nov 2025 10:58:47 -0500 Subject: [PATCH 3/6] tsk-207: Moving file around --- src/{auth.rs => auth/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{auth.rs => auth/mod.rs} (100%) diff --git a/src/auth.rs b/src/auth/mod.rs similarity index 100% rename from src/auth.rs rename to src/auth/mod.rs -- 2.47.3 From 531d6ee01e0e88bb291e328d36be3f8a6c58863f Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 4 Nov 2025 11:00:37 -0500 Subject: [PATCH 4/6] tsk-207: Code formatting --- src/config/init.rs | 20 +++++++++----------- src/main.rs | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/config/init.rs b/src/config/init.rs index 6505280..c41029b 100644 --- a/src/config/init.rs +++ b/src/config/init.rs @@ -130,10 +130,9 @@ pub async fn routes() -> axum::Router { ) .route( crate::callers::queue::endpoints::QUEUESONGDATAWIPE, - patch(crate::callers::queue::song::endpoint::wipe_data_from_song_queue) - .route_layer(axum::middleware::from_fn( - crate::auth::auth::, - )), + patch(crate::callers::queue::song::endpoint::wipe_data_from_song_queue).route_layer( + axum::middleware::from_fn(crate::auth::auth::), + ), ) .route( crate::callers::queue::endpoints::QUEUEMETADATA, @@ -155,10 +154,9 @@ pub async fn routes() -> axum::Router { ) .route( crate::callers::queue::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::queue::endpoints::QUEUECOVERART, @@ -193,9 +191,9 @@ pub async fn routes() -> axum::Router { ) .route( crate::callers::endpoints::GETSONGS, - get(crate::callers::song::endpoint::get_songs).route_layer( - axum::middleware::from_fn(crate::auth::auth::), - ), + get(crate::callers::song::endpoint::get_songs).route_layer(axum::middleware::from_fn( + crate::auth::auth::, + )), ) .route( crate::callers::endpoints::GETCOVERART, diff --git a/src/main.rs b/src/main.rs index d313d3d..1c5d1b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,9 @@ pub mod auth; -pub mod db; pub mod callers; pub mod config; +pub mod db; pub mod repo; - #[tokio::main] async fn main() { // initialize tracing -- 2.47.3 From 07092a9cc70fd8428e38b93f8a6759103d5d86f0 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 4 Nov 2025 11:01:08 -0500 Subject: [PATCH 5/6] tsk-207: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1235bd8..a85efbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "icarus" -version = "0.3.24" +version = "0.3.25" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index 0c23ab7..8616ac1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus" -version = "0.3.24" +version = "0.3.25" edition = "2024" rust-version = "1.90" -- 2.47.3 From 9d2bae7c29f0579269a524aa207f74c77eb21e0e Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 4 Nov 2025 11:12:59 -0500 Subject: [PATCH 6/6] tsk-207: Test fix --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1c5d1b5..af168ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,7 +107,7 @@ mod tests { mod init { pub async fn app(pool: sqlx::PgPool) -> axum::Router { - crate::init::routes() + crate::config::init::routes() .await .layer(axum::Extension(pool)) .layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024)) -- 2.47.3