fix: get request on a single project
Some checks failed
ci/woodpecker/push/check_fmt Pipeline failed

This commit is contained in:
Mika 2025-04-02 20:18:18 +02:00
parent c1e5f60fac
commit d6714aa7d9
3 changed files with 8 additions and 11 deletions

View file

@ -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<Database>,
) -> Result<web::Json<Vec<entity::project::Model>>, 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<Database>,
path: web::Path<Uuid>,
) -> Result<web::Json<entity::project::Model>, ApiError> {
debug!("Fetching project with id: {}", path);
let id = path.into_inner();
let project = db.get_project(&id).await?;

View file

@ -15,7 +15,6 @@ impl Database {
Ok(projects)
}
// TODO: This is not working yet
pub async fn get_project(&self, id: &Uuid) -> Result<Option<project::Model>, ApiError> {
debug!("Fetching project with id: {}", id);

View file

@ -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()