From 227cd926ca6d5ef071a2d48ef3e1bc5bddcd1972 Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 22 Apr 2025 20:00:49 -0400 Subject: [PATCH] Code cleanup --- Cargo.toml | 8 +------- src/callers/song.rs | 11 +++++------ src/main.rs | 10 ---------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d6c36f8..a0d8df6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,11 +24,5 @@ icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" } [dev-dependencies] -http-body-util = { version = "0.1.3" } common-multipart-rfc7578 = { version = "0.7.0" } -anyhow = { version = "1.0.98" } -url = { version = "2.5.4" } -reqwest = { version = "0.12.15", features = ["stream", "multipart"] } -axum-test = { version = "17.3.0" } -hyper = { version = "1.6.0" } -base64 = "0.22.1" \ No newline at end of file +url = { version = "2.5.4" } \ No newline at end of file diff --git a/src/callers/song.rs b/src/callers/song.rs index 8e7968d..a98d0a7 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -58,7 +58,6 @@ mod song_queue { pub mod endpoint { use axum::{Json, http::StatusCode}; - // use axum::extract::M use std::io::Write; use crate::callers::song::song_queue; @@ -66,7 +65,6 @@ pub mod endpoint { pub async fn queue_song( axum::Extension(pool): axum::Extension, mut multipart: axum::extract::Multipart, - // Json(payload): Json, ) -> (StatusCode, Json) { let mut results: Vec = Vec::new(); let mut response = super::response::Response::default(); @@ -75,10 +73,6 @@ pub mod endpoint { let name = field.name().unwrap().to_string(); let file_name = field.file_name().unwrap().to_string(); let content_type = field.content_type().unwrap().to_string(); - println!( - "Name {} filename {} content type {}", - name, file_name, content_type - ); let data = field.bytes().await.unwrap(); println!( @@ -101,6 +95,11 @@ pub mod endpoint { } response.data = results; + response.message = if response.data.is_empty() { + String::from("Error") + } else { + String::from("Success") + }; (StatusCode::OK, Json(response)) } diff --git a/src/main.rs b/src/main.rs index 6dba763..0343b28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -// use serde::{Deserialize, Serialize}; - pub mod callers; pub mod db { @@ -19,8 +17,6 @@ pub mod db { } } - // use crate::{connection_settings, keys}; - pub async fn create_pool() -> Result { let database_url = get_db_url().await; println!("Database url: {:?}", database_url); @@ -32,7 +28,6 @@ pub mod db { } async fn get_db_url() -> String { - // #[cfg(debug_assertions)] // Example: Only load .env in debug builds dotenvy::dotenv().ok(); env::var(keys::DBURL).expect(keys::error::ERROR) } @@ -57,11 +52,7 @@ async fn main() { // build our application with a route let app = init::app().await; - // `GET /` goes to `root` - // `POST /users` goes to `create_user` - // .route("/users", post(create_user)); - // run our app with hyper, listening globally on port 3000 let listener = tokio::net::TcpListener::bind(get_full()).await.unwrap(); axum::serve(listener, app).await.unwrap(); } @@ -73,7 +64,6 @@ pub mod init { pub async fn routes() -> axum::Router { axum::Router::new() - // `GET /` goes to `root` .route(crate::ROOT, get(crate::root)) .route( crate::callers::endpoints::QUEUESONG,