tsk-271: Rrrrrr
This commit is contained in:
2 files changed
+100
-85
No files matched your search
@@ -1,8 +1,4 @@
|
||||
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";
|
||||
|
||||
+100
-81
@@ -1,15 +1,20 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use axum::routing::{delete, get, patch, post};
|
||||
use axum::body::Body as AxumBody;
|
||||
use tower_http::timeout::TimeoutLayer;
|
||||
use utoipa::OpenApi;
|
||||
|
||||
use crate::callers::coverart as coverart_caller;
|
||||
use crate::callers::playback::queue as playback_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 crate::auth::auth;
|
||||
use crate::callers;
|
||||
use crate::db;
|
||||
use callers::coverart as coverart_caller;
|
||||
use callers::playback::queue as playback_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::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,
|
||||
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, 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,
|
||||
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, 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(
|
||||
(name = "soaricarus API", description = "Web API to manage music")
|
||||
)
|
||||
@@ -93,157 +100,169 @@ struct ApiDoc;
|
||||
|
||||
pub async fn routes() -> axum::Router {
|
||||
axum::Router::new()
|
||||
.route(crate::callers::endpoints::ROOT, get(crate::callers::root))
|
||||
.route(endpoints::ROOT, get(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::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUESONG,
|
||||
post(callers::queue::song::endpoint::queue_song).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.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::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUESONG,
|
||||
patch(callers::queue::song::endpoint::update_song_queue_status).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUESONGLINKUSERID,
|
||||
patch(crate::callers::queue::song::endpoint::link_user_id).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUESONGLINKUSERID,
|
||||
patch(callers::queue::song::endpoint::link_user_id).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUESONGDATA,
|
||||
get(crate::callers::queue::song::endpoint::download_queued_song).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUESONGDATA,
|
||||
get(callers::queue::song::endpoint::download_queued_song).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::NEXTQUEUESONG,
|
||||
get(crate::callers::queue::song::endpoint::fetch_queue_song).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::NEXTQUEUESONG,
|
||||
get(callers::queue::song::endpoint::fetch_queue_song).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUESONGUPDATE,
|
||||
patch(crate::callers::queue::song::endpoint::update_song_queue).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUESONGUPDATE,
|
||||
patch(callers::queue::song::endpoint::update_song_queue).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.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::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUESONGDATAWIPE,
|
||||
patch(callers::queue::song::endpoint::wipe_data_from_song_queue).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUEMETADATA,
|
||||
post(crate::callers::queue::metadata::endpoint::queue_metadata).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUEMETADATA,
|
||||
post(callers::queue::metadata::endpoint::queue_metadata).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUEMETADATA,
|
||||
get(crate::callers::queue::metadata::endpoint::fetch_metadata).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUEMETADATA,
|
||||
get(callers::queue::metadata::endpoint::fetch_metadata).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUECOVERART,
|
||||
post(crate::callers::queue::coverart::endpoint::queue).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUECOVERART,
|
||||
post(callers::queue::coverart::endpoint::queue).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.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::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUECOVERARTDATA,
|
||||
get(callers::queue::coverart::endpoint::fetch_coverart_with_data).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.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::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUECOVERART,
|
||||
get(callers::queue::coverart::endpoint::fetch_coverart_no_data).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUECOVERARTLINK,
|
||||
patch(crate::callers::queue::coverart::endpoint::link).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
callers::queue::endpoints::QUEUECOVERARTLINK,
|
||||
patch(callers::queue::coverart::endpoint::link).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE,
|
||||
patch(crate::callers::queue::coverart::endpoint::wipe_data_from_coverart_queue)
|
||||
callers::queue::endpoints::QUEUECOVERARTDATAWIPE,
|
||||
patch(callers::queue::coverart::endpoint::wipe_data_from_coverart_queue)
|
||||
.route_layer(axum::middleware::from_fn(
|
||||
crate::auth::auth::<axum::body::Body>,
|
||||
auth::<AxumBody>,
|
||||
)),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::CREATESONG,
|
||||
post(crate::callers::song::endpoint::create_metadata).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::CREATESONG,
|
||||
post(callers::song::endpoint::create_metadata).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::CREATECOVERART,
|
||||
post(crate::callers::coverart::endpoint::create_coverart).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::CREATECOVERART,
|
||||
post(callers::coverart::endpoint::create_coverart).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::GETSONGS,
|
||||
get(crate::callers::song::endpoint::get_songs).route_layer(axum::middleware::from_fn(
|
||||
crate::auth::auth::<axum::body::Body>,
|
||||
endpoints::GETSONGS,
|
||||
get(callers::song::endpoint::get_songs).route_layer(axum::middleware::from_fn(
|
||||
auth::<AxumBody>,
|
||||
)),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::GETCOVERART,
|
||||
get(crate::callers::coverart::endpoint::get_coverart).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::GETCOVERART,
|
||||
get(callers::coverart::endpoint::get_coverart).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::DOWNLOADCOVERART,
|
||||
get(crate::callers::coverart::endpoint::download_coverart).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::DOWNLOADCOVERART,
|
||||
get(callers::coverart::endpoint::download_coverart).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::STREAMSONG,
|
||||
get(crate::callers::song::endpoint::stream_song).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::STREAMSONG,
|
||||
get(callers::song::endpoint::stream_song).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::DOWNLOADSONG,
|
||||
get(crate::callers::song::endpoint::download_song).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::DOWNLOADSONG,
|
||||
get(callers::song::endpoint::download_song).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::DELETESONG,
|
||||
delete(crate::callers::song::endpoint::delete_song).route_layer(
|
||||
axum::middleware::from_fn(crate::auth::auth::<axum::body::Body>),
|
||||
endpoints::DELETESONG,
|
||||
delete(callers::song::endpoint::delete_song).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::GETALLSONGS,
|
||||
get(crate::callers::song::endpoint::get_all_songs),
|
||||
endpoints::GETALLSONGS,
|
||||
get(callers::song::endpoint::get_all_songs).route_layer(
|
||||
axum::middleware::from_fn(auth::<AxumBody>),
|
||||
),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::CREATEPLAYBACKQUEUE,
|
||||
post(playback_endpoints::create_playback_queue),
|
||||
endpoints::CREATEPLAYBACKQUEUE,
|
||||
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)
|
||||
}
|
||||
|
||||
pub async fn app() -> axum::Router {
|
||||
let pool = crate::db::create_pool()
|
||||
let pool = db::create_pool()
|
||||
.await
|
||||
.expect("Failed to create pool");
|
||||
|
||||
crate::db::migrations(&pool).await;
|
||||
db::migrations(&pool).await;
|
||||
|
||||
let cors = cors::configure_cors().await;
|
||||
|
||||
|
||||
Reference in new issue
Block a user