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