From d6714aa7d99fbfa78fb0a075866c01ef0be49371 Mon Sep 17 00:00:00 2001 From: Mika Date: Wed, 2 Apr 2025 20:18:18 +0200 Subject: [PATCH] fix: get request on a single project --- crates/backend/src/controller/project.rs | 12 +++++------- crates/backend/src/db/project.rs | 1 - crates/backend/src/main.rs | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/crates/backend/src/controller/project.rs b/crates/backend/src/controller/project.rs index e2c9c46..c4c8ccf 100644 --- a/crates/backend/src/controller/project.rs +++ b/crates/backend/src/controller/project.rs @@ -1,4 +1,4 @@ -use actix_web::{Responder, Result, delete, get, post, web}; +use actix_web::{Result, delete, get, post, web}; use log::debug; use sea_orm::prelude::Uuid; use serde::Deserialize; @@ -12,17 +12,16 @@ struct CreateProject { } pub fn setup(cfg: &mut actix_web::web::ServiceConfig) { - cfg.service(create_project) - .service(delete_project) - .service(get_projects); + cfg.service(get_project) + .service(get_projects) + .service(create_project) + .service(delete_project); } #[get("")] async fn get_projects( db: web::Data, ) -> Result>, ApiError> { - debug!("Fetching all projects"); - let projects = db.get_projects().await?; Ok(web::Json(projects)) @@ -33,7 +32,6 @@ async fn get_project( db: web::Data, path: web::Path, ) -> Result, ApiError> { - debug!("Fetching project with id: {}", path); let id = path.into_inner(); let project = db.get_project(&id).await?; diff --git a/crates/backend/src/db/project.rs b/crates/backend/src/db/project.rs index 72c1f1f..2ddfdf5 100644 --- a/crates/backend/src/db/project.rs +++ b/crates/backend/src/db/project.rs @@ -15,7 +15,6 @@ impl Database { Ok(projects) } - // TODO: This is not working yet pub async fn get_project(&self, id: &Uuid) -> Result, ApiError> { debug!("Fetching project with id: {}", id); diff --git a/crates/backend/src/main.rs b/crates/backend/src/main.rs index 918d9d8..2601185 100644 --- a/crates/backend/src/main.rs +++ b/crates/backend/src/main.rs @@ -3,7 +3,7 @@ use actix_session::{SessionMiddleware, storage::RedisSessionStore}; use actix_web::{App, HttpResponse, HttpServer, cookie::Key, middleware::Logger, web}; use argon2::Argon2; use db::Database; -use std::env; +use log::debug; mod controller; mod db; @@ -11,8 +11,8 @@ mod error; #[actix_web::main] async fn main() -> std::io::Result<()> { - env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); dotenvy::dotenv().ok(); + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); let database_url = build_database_url(); @@ -22,7 +22,7 @@ async fn main() -> std::io::Result<()> { // use dotenvy here to get SECRET_KEY let secret_key = Key::generate(); - println!("Secret Key {:?}", secret_key.master()); + debug!("Secret Key {:?}", secret_key.master()); HttpServer::new(move || { let app = App::new()