Started working on a cli frontend.

This commit is contained in:
2025-04-23 20:27:06 +02:00
parent 02913c7b52
commit db25dc0aed
49 changed files with 3838 additions and 59 deletions

View File

@@ -6,7 +6,7 @@ use crate::schema::{self};
use crate::schema::user::User;
use crate::request::requests::GamenightGet;
use crate::request::requests::GamenightPost;
use crate::request::responses::GameNightResponse;
use crate::request::responses::GameNightsResponse;
use crate::request::error::ApiError;
use crate::DbPool;
use crate::util::GetConnection;
@@ -31,11 +31,11 @@ impl Into<Uuid> for GamenightGet {
#[get("/gamenights")]
pub async fn gamenights(pool: web::Data<DbPool>, _user: User) -> Result<impl Responder, ApiError> {
let mut conn = pool.get_conn();
let gamenights = schema::gamenights(&mut conn)?;
let gamenights: GameNightsResponse = schema::gamenights(&mut conn)?;
Ok(HttpResponse::Ok()
.content_type(ContentType::json())
.body(serde_json::to_string(&GameNightResponse { gamenights })?)
.body(serde_json::to_string(&gamenights)?)
)
}

View File

@@ -22,7 +22,4 @@ impl LoginResponse {
}
}
#[derive(Serialize, Deserialize)]
pub struct GameNightResponse {
pub gamenights: Vec::<Gamenight>
}
pub type GameNightsResponse = Vec<Gamenight>;

View File

@@ -1,6 +1,6 @@
use actix_web::http::header::ContentType;
use actix_web::{web, post, HttpResponse, Responder};
use actix_web::{web, get, post, HttpResponse, Responder};
use validator::ValidateArgs;
use crate::DbPool;
use crate::request::requests::{Login, Register, RegisterContext};
@@ -30,7 +30,7 @@ impl Into<schema::user::Register> for Register {
}
}
#[post("/token")]
#[get("/token")]
pub async fn login(pool: web::Data<DbPool>, login_data: web::Json<Login>) -> Result<impl Responder, ApiError> {
let data = login_data.into_inner();