tsk-194: Moving metadata module
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
pub mod coverart;
|
pub mod coverart;
|
||||||
pub mod metadata;
|
|
||||||
pub mod queue;
|
pub mod queue;
|
||||||
pub mod song;
|
pub mod song;
|
||||||
|
|
||||||
pub mod endpoints {
|
pub mod endpoints {
|
||||||
pub const QUEUEMETADATA: &str = "/api/v2/song/metadata/queue";
|
|
||||||
|
|
||||||
pub const CREATESONG: &str = "/api/v2/song";
|
pub const CREATESONG: &str = "/api/v2/song";
|
||||||
pub const GETSONGS: &str = "/api/v2/song";
|
pub const GETSONGS: &str = "/api/v2/song";
|
||||||
pub const GETALLSONGS: &str = "/api/v2/song/all";
|
pub const GETALLSONGS: &str = "/api/v2/song/all";
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
// TODO: Explicitly make this module target queueing a song's metadata
|
|
||||||
pub mod request {
|
pub mod request {
|
||||||
pub mod queue_metadata {
|
pub mod queue_metadata {
|
||||||
use serde::{Deserialize, Serialize};
|
#[derive(Debug, Default, serde::Deserialize, serde::Serialize, sqlx::FromRow, utoipa::ToSchema)]
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Serialize, sqlx::FromRow, utoipa::ToSchema)]
|
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
pub song_queue_id: uuid::Uuid,
|
pub song_queue_id: uuid::Uuid,
|
||||||
pub album: String,
|
pub album: String,
|
||||||
@@ -59,9 +56,7 @@ pub mod request {
|
|||||||
|
|
||||||
pub mod response {
|
pub mod response {
|
||||||
pub mod queue_metadata {
|
pub mod queue_metadata {
|
||||||
use serde::{Deserialize, Serialize};
|
#[derive(Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<uuid::Uuid>,
|
pub data: Vec<uuid::Uuid>,
|
||||||
@@ -69,9 +64,7 @@ pub mod response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod fetch_metadata {
|
pub mod fetch_metadata {
|
||||||
use serde::{Deserialize, Serialize};
|
#[derive(Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<crate::repo::queue::metadata::MetadataQueue>,
|
pub data: Vec<crate::repo::queue::metadata::MetadataQueue>,
|
||||||
@@ -81,8 +74,6 @@ pub mod response {
|
|||||||
|
|
||||||
/// Module for metadata related endpoints
|
/// Module for metadata related endpoints
|
||||||
pub mod endpoint {
|
pub mod endpoint {
|
||||||
use axum::{Json, http::StatusCode};
|
|
||||||
|
|
||||||
use crate::repo::queue as repo_queue;
|
use crate::repo::queue as repo_queue;
|
||||||
|
|
||||||
/// Endpoint to create queued metadata
|
/// Endpoint to create queued metadata
|
||||||
@@ -101,8 +92,8 @@ pub mod endpoint {
|
|||||||
)]
|
)]
|
||||||
pub async fn queue_metadata(
|
pub async fn queue_metadata(
|
||||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||||
Json(payload): Json<super::request::queue_metadata::Request>,
|
axum::Json(payload): axum::Json<super::request::queue_metadata::Request>,
|
||||||
) -> (StatusCode, Json<super::response::queue_metadata::Response>) {
|
) -> (axum::http::StatusCode, axum::Json<super::response::queue_metadata::Response>) {
|
||||||
let mut results: Vec<uuid::Uuid> = Vec::new();
|
let mut results: Vec<uuid::Uuid> = Vec::new();
|
||||||
let mut response = super::response::queue_metadata::Response::default();
|
let mut response = super::response::queue_metadata::Response::default();
|
||||||
let meta = payload.to_json_value().await;
|
let meta = payload.to_json_value().await;
|
||||||
@@ -113,14 +104,14 @@ pub mod endpoint {
|
|||||||
response.message = if response.data.is_empty() {
|
response.message = if response.data.is_empty() {
|
||||||
String::from("Error")
|
String::from("Error")
|
||||||
} else {
|
} else {
|
||||||
String::from(super::super::response::SUCCESSFUL)
|
String::from(super::super::super::response::SUCCESSFUL)
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::OK, Json(response))
|
(axum::http::StatusCode::OK, axum::Json(response))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
(StatusCode::BAD_REQUEST, Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +132,7 @@ pub mod endpoint {
|
|||||||
pub async fn fetch_metadata(
|
pub async fn fetch_metadata(
|
||||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||||
axum::extract::Query(params): axum::extract::Query<super::request::fetch_metadata::Params>,
|
axum::extract::Query(params): axum::extract::Query<super::request::fetch_metadata::Params>,
|
||||||
) -> (StatusCode, Json<super::response::fetch_metadata::Response>) {
|
) -> (axum::http::StatusCode, axum::Json<super::response::fetch_metadata::Response>) {
|
||||||
let mut response = super::response::fetch_metadata::Response::default();
|
let mut response = super::response::fetch_metadata::Response::default();
|
||||||
|
|
||||||
match params.id {
|
match params.id {
|
||||||
@@ -152,11 +143,11 @@ pub mod endpoint {
|
|||||||
Ok(item) => {
|
Ok(item) => {
|
||||||
response.message = String::from("Successful");
|
response.message = String::from("Successful");
|
||||||
response.data.push(item);
|
response.data.push(item);
|
||||||
(StatusCode::OK, Json(response))
|
(axum::http::StatusCode::OK, axum::Json(response))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
(StatusCode::BAD_REQUEST, Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,17 +159,17 @@ pub mod endpoint {
|
|||||||
Ok(item) => {
|
Ok(item) => {
|
||||||
response.message = String::from("Successful");
|
response.message = String::from("Successful");
|
||||||
response.data.push(item);
|
response.data.push(item);
|
||||||
(StatusCode::OK, Json(response))
|
(axum::http::StatusCode::OK, axum::Json(response))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
(StatusCode::BAD_REQUEST, Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
println!("What is going on?");
|
println!("What is going on?");
|
||||||
(StatusCode::BAD_REQUEST, Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
pub mod coverart;
|
pub mod coverart;
|
||||||
|
pub mod metadata;
|
||||||
pub mod song;
|
pub mod song;
|
||||||
|
|
||||||
pub mod endpoints {
|
pub mod endpoints {
|
||||||
@@ -7,6 +8,7 @@ pub mod endpoints {
|
|||||||
pub const QUEUESONGDATA: &str = "/api/v2/song/queue/{id}";
|
pub const QUEUESONGDATA: &str = "/api/v2/song/queue/{id}";
|
||||||
pub const QUEUESONGUPDATE: &str = "/api/v2/song/queue/{id}";
|
pub const QUEUESONGUPDATE: &str = "/api/v2/song/queue/{id}";
|
||||||
pub const NEXTQUEUESONG: &str = "/api/v2/song/queue/next";
|
pub const NEXTQUEUESONG: &str = "/api/v2/song/queue/next";
|
||||||
|
pub const QUEUEMETADATA: &str = "/api/v2/song/metadata/queue";
|
||||||
pub const QUEUECOVERART: &str = "/api/v2/coverart/queue";
|
pub const QUEUECOVERART: &str = "/api/v2/coverart/queue";
|
||||||
pub const QUEUECOVERARTDATA: &str = "/api/v2/coverart/queue/data/{id}";
|
pub const QUEUECOVERARTDATA: &str = "/api/v2/coverart/queue/data/{id}";
|
||||||
pub const QUEUECOVERARTLINK: &str = "/api/v2/coverart/queue/link";
|
pub const QUEUECOVERARTLINK: &str = "/api/v2/coverart/queue/link";
|
||||||
|
|||||||
Reference in New Issue
Block a user