diff options
Diffstat (limited to 'crates/rocie-server/src/api/set/recipe.rs')
| -rw-r--r-- | crates/rocie-server/src/api/set/recipe.rs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/crates/rocie-server/src/api/set/recipe.rs b/crates/rocie-server/src/api/set/recipe.rs deleted file mode 100644 index bb5be37..0000000 --- a/crates/rocie-server/src/api/set/recipe.rs +++ /dev/null @@ -1,54 +0,0 @@ -use std::path::PathBuf; - -use actix_web::{HttpResponse, Responder, error::Result, post, web}; -use serde::Deserialize; -use utoipa::ToSchema; - -use crate::{ - app::App, - storage::sql::{ - insert::Operations, - recipe::{Recipe, RecipeId}, - }, -}; - -#[derive(Deserialize, ToSchema)] -struct RecipeStub { - /// The path the recipe should have - #[schema(value_type = String)] - path: PathBuf, - - /// The content of this recipe, in cooklang format - content: String, -} - -/// Register a product parent -#[utoipa::path( - responses( - ( - status = 200, - description = "Product parent successfully registered in database", - body = RecipeId, - ), - ( - status = INTERNAL_SERVER_ERROR, - description = "Server encountered error", - body = String, - ) - ), - request_body = RecipeStub, -)] -#[post("/recipe/new")] -pub(crate) async fn add_recipe( - app: web::Data<App>, - stub: web::Json<RecipeStub>, -) -> Result<impl Responder> { - let stub = stub.into_inner(); - let mut ops = Operations::new("add recipe parent"); - - let recipe = Recipe::new(stub.path, stub.content, &mut ops); - - ops.apply(&app).await?; - - Ok(HttpResponse::Ok().json(recipe.id)) -} |
