tsk-271: Rrrrrr

This commit is contained in:
phoenix committed 2026-11-21 12:40:56 -05:00
1 parent e416aa6723
commit d39622f953
2 files changed
+100 -85

No files matched your search

-4
View File
@@ -1,8 +1,4 @@
pub mod queue { pub mod queue {
use axum::http;
use tower_http::classify::StatusInRangeFailureClass::StatusCode;
use crate::callers::playback::queue::response::GetPlaybackQueueResponse;
const PLAYBACK_QUEUE_DEVICE_TYPE_BROWSER: &str = "BROWSER"; const PLAYBACK_QUEUE_DEVICE_TYPE_BROWSER: &str = "BROWSER";
+100 -81
View File
@@ -1,15 +1,20 @@
use std::time::Duration; use std::time::Duration;
use axum::routing::{delete, get, patch, post}; use axum::routing::{delete, get, patch, post};
use axum::body::Body as AxumBody;
use tower_http::timeout::TimeoutLayer; use tower_http::timeout::TimeoutLayer;
use utoipa::OpenApi; use utoipa::OpenApi;
use crate::callers::coverart as coverart_caller; use crate::auth::auth;
use crate::callers::playback::queue as playback_caller; use crate::callers;
use crate::callers::queue::coverart as coverart_queue_callers; use crate::db;
use crate::callers::queue::metadata as metadata_queue_caller; use callers::coverart as coverart_caller;
use crate::callers::queue::song as song_queue_callers; use callers::playback::queue as playback_caller;
use crate::callers::song as song_caller; use callers::queue::coverart as coverart_queue_callers;
use callers::queue::metadata as metadata_queue_caller;
use callers::queue::song as song_queue_callers;
use callers::song as song_caller;
use callers::endpoints;
use coverart_caller::endpoint as coverart_endpoints; use coverart_caller::endpoint as coverart_endpoints;
use coverart_caller::response as coverart_responses; use coverart_caller::response as coverart_responses;
@@ -77,14 +82,16 @@ mod cors {
song_endpoints::delete_song, coverart_queue_endpoints::queue, coverart_queue_endpoints::link, coverart_queue_endpoints::fetch_coverart_no_data, 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_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, coverart_endpoints::get_coverart, coverart_endpoints::download_coverart,
metadata_queue_endpoints::queue_metadata, metadata_queue_endpoints::fetch_metadata, playback_endpoints::create_playback_queue), metadata_queue_endpoints::queue_metadata, metadata_queue_endpoints::fetch_metadata, playback_endpoints::create_playback_queue,
playback_endpoints::get_playback_queue),
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, 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_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, 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::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::fetch_coverart_with_data::Response, coverart_responses::create_coverart::Response,
coverart_queue_responses::wipe_data_from_coverart_queue::Response, coverart_responses::get_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, playback_responses::create_playback_queue::CreatePlaybackQueueResponse)), metadata_queue_responses::queue_metadata::Response, metadata_queue_responses::fetch_metadata::Response, playback_responses::create_playback_queue::CreatePlaybackQueueResponse,
playback_responses::GetPlaybackQueueResponse)),
tags( tags(
(name = "soaricarus API", description = "Web API to manage music") (name = "soaricarus API", description = "Web API to manage music")
) )
@@ -93,157 +100,169 @@ struct ApiDoc;
pub async fn routes() -> axum::Router { pub async fn routes() -> axum::Router {
axum::Router::new() axum::Router::new()
.route(crate::callers::endpoints::ROOT, get(crate::callers::root)) .route(endpoints::ROOT, get(callers::root))
.route( .route(
crate::callers::queue::endpoints::QUEUESONG, callers::queue::endpoints::QUEUESONG,
post(crate::callers::queue::song::endpoint::queue_song).route_layer( post(callers::queue::song::endpoint::queue_song).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUESONG, callers::queue::endpoints::QUEUESONG,
patch(crate::callers::queue::song::endpoint::update_song_queue_status).route_layer( patch(callers::queue::song::endpoint::update_song_queue_status).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUESONGLINKUSERID, callers::queue::endpoints::QUEUESONGLINKUSERID,
patch(crate::callers::queue::song::endpoint::link_user_id).route_layer( patch(callers::queue::song::endpoint::link_user_id).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUESONGDATA, callers::queue::endpoints::QUEUESONGDATA,
get(crate::callers::queue::song::endpoint::download_queued_song).route_layer( get(callers::queue::song::endpoint::download_queued_song).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::NEXTQUEUESONG, callers::queue::endpoints::NEXTQUEUESONG,
get(crate::callers::queue::song::endpoint::fetch_queue_song).route_layer( get(callers::queue::song::endpoint::fetch_queue_song).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUESONGUPDATE, callers::queue::endpoints::QUEUESONGUPDATE,
patch(crate::callers::queue::song::endpoint::update_song_queue).route_layer( patch(callers::queue::song::endpoint::update_song_queue).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUESONGDATAWIPE, callers::queue::endpoints::QUEUESONGDATAWIPE,
patch(crate::callers::queue::song::endpoint::wipe_data_from_song_queue).route_layer( patch(callers::queue::song::endpoint::wipe_data_from_song_queue).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUEMETADATA, callers::queue::endpoints::QUEUEMETADATA,
post(crate::callers::queue::metadata::endpoint::queue_metadata).route_layer( post(callers::queue::metadata::endpoint::queue_metadata).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUEMETADATA, callers::queue::endpoints::QUEUEMETADATA,
get(crate::callers::queue::metadata::endpoint::fetch_metadata).route_layer( get(callers::queue::metadata::endpoint::fetch_metadata).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUECOVERART, callers::queue::endpoints::QUEUECOVERART,
post(crate::callers::queue::coverart::endpoint::queue).route_layer( post(callers::queue::coverart::endpoint::queue).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUECOVERARTDATA, callers::queue::endpoints::QUEUECOVERARTDATA,
get(crate::callers::queue::coverart::endpoint::fetch_coverart_with_data).route_layer( get(callers::queue::coverart::endpoint::fetch_coverart_with_data).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUECOVERART, callers::queue::endpoints::QUEUECOVERART,
get(crate::callers::queue::coverart::endpoint::fetch_coverart_no_data).route_layer( get(callers::queue::coverart::endpoint::fetch_coverart_no_data).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUECOVERARTLINK, callers::queue::endpoints::QUEUECOVERARTLINK,
patch(crate::callers::queue::coverart::endpoint::link).route_layer( patch(callers::queue::coverart::endpoint::link).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE, callers::queue::endpoints::QUEUECOVERARTDATAWIPE,
patch(crate::callers::queue::coverart::endpoint::wipe_data_from_coverart_queue) patch(callers::queue::coverart::endpoint::wipe_data_from_coverart_queue)
.route_layer(axum::middleware::from_fn( .route_layer(axum::middleware::from_fn(
crate::auth::auth::<axum::body::Body>, auth::<AxumBody>,
)), )),
) )
.route( .route(
crate::callers::endpoints::CREATESONG, endpoints::CREATESONG,
post(crate::callers::song::endpoint::create_metadata).route_layer( post(callers::song::endpoint::create_metadata).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::CREATECOVERART, endpoints::CREATECOVERART,
post(crate::callers::coverart::endpoint::create_coverart).route_layer( post(callers::coverart::endpoint::create_coverart).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::GETSONGS, endpoints::GETSONGS,
get(crate::callers::song::endpoint::get_songs).route_layer(axum::middleware::from_fn( get(callers::song::endpoint::get_songs).route_layer(axum::middleware::from_fn(
crate::auth::auth::<axum::body::Body>, auth::<AxumBody>,
)), )),
) )
.route( .route(
crate::callers::endpoints::GETCOVERART, endpoints::GETCOVERART,
get(crate::callers::coverart::endpoint::get_coverart).route_layer( get(callers::coverart::endpoint::get_coverart).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::DOWNLOADCOVERART, endpoints::DOWNLOADCOVERART,
get(crate::callers::coverart::endpoint::download_coverart).route_layer( get(callers::coverart::endpoint::download_coverart).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::STREAMSONG, endpoints::STREAMSONG,
get(crate::callers::song::endpoint::stream_song).route_layer( get(callers::song::endpoint::stream_song).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::DOWNLOADSONG, endpoints::DOWNLOADSONG,
get(crate::callers::song::endpoint::download_song).route_layer( get(callers::song::endpoint::download_song).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::DELETESONG, endpoints::DELETESONG,
delete(crate::callers::song::endpoint::delete_song).route_layer( delete(callers::song::endpoint::delete_song).route_layer(
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>), axum::middleware::from_fn(auth::<AxumBody>),
), ),
) )
.route( .route(
crate::callers::endpoints::GETALLSONGS, endpoints::GETALLSONGS,
get(crate::callers::song::endpoint::get_all_songs), get(callers::song::endpoint::get_all_songs).route_layer(
axum::middleware::from_fn(auth::<AxumBody>),
),
) )
.route( .route(
crate::callers::endpoints::CREATEPLAYBACKQUEUE, endpoints::CREATEPLAYBACKQUEUE,
post(playback_endpoints::create_playback_queue), post(playback_endpoints::create_playback_queue)
.route_layer(
axum::middleware::from_fn(auth::<AxumBody>),
),
)
.route(
endpoints::GETPLAYBACKQUEUE,
get(playback_endpoints::get_playback_queue)
.route_layer(
axum::middleware::from_fn(auth::<AxumBody>),
),
) )
.layer(cors::configure_cors().await) .layer(cors::configure_cors().await)
} }
pub async fn app() -> axum::Router { pub async fn app() -> axum::Router {
let pool = crate::db::create_pool() let pool = db::create_pool()
.await .await
.expect("Failed to create pool"); .expect("Failed to create pool");
crate::db::migrations(&pool).await; db::migrations(&pool).await;
let cors = cors::configure_cors().await; let cors = cors::configure_cors().await;