Refactoring the structure a bit

This commit is contained in:
Dave
2026-02-16 16:24:21 +00:00
parent a2188e2c7f
commit 5923165fcf
21 changed files with 522 additions and 372 deletions

View File

@@ -0,0 +1,24 @@
use crate::http::context::{AppContext, OpenApiResult, bad_request};
use crate::http::payloads::PathPayload;
use crate::io::fs;
use poem_openapi::payload::Json;
pub async fn get_current_project(ctx: &AppContext) -> OpenApiResult<Json<Option<String>>> {
let result = fs::get_current_project(&ctx.state, ctx.store.as_ref()).map_err(bad_request)?;
Ok(Json(result))
}
pub async fn open_project(
payload: Json<PathPayload>,
ctx: &AppContext,
) -> OpenApiResult<Json<String>> {
let confirmed = fs::open_project(payload.0.path, &ctx.state, ctx.store.as_ref())
.await
.map_err(bad_request)?;
Ok(Json(confirmed))
}
pub async fn close_project(ctx: &AppContext) -> OpenApiResult<Json<bool>> {
fs::close_project(&ctx.state, ctx.store.as_ref()).map_err(bad_request)?;
Ok(Json(true))
}