add createOrUpdate for recipes
This commit is contained in:
parent
7252b072bd
commit
58ef7fbc00
4 changed files with 54 additions and 0 deletions
|
|
@ -16,6 +16,8 @@ const compactRecipeHandler = new CompactRecipeHandler(recipeRepository, compactR
|
|||
/**
|
||||
* Load header data of all recipes
|
||||
* Responds with a list of CompactRecipeDtos
|
||||
* @todo request wrapper DTO
|
||||
* @todo response wrapper DTO
|
||||
*/
|
||||
router.get(
|
||||
"/",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const recipeController = new RecipeHandler(recipeRepository, recipeMapper);
|
|||
* Create new recipe
|
||||
* Consumes: RecipeDto
|
||||
* Responds with RecipeDto
|
||||
* DEPRECATED!
|
||||
*/
|
||||
router.post(
|
||||
"/",
|
||||
|
|
@ -36,6 +37,23 @@ router.post(
|
|||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Save or update recipe.
|
||||
* Consumes: RecipeDto
|
||||
* Responds with RecipeDto as saved in database
|
||||
* A new recipe is created if the dto doesn't contain an ID. Otherwise, the
|
||||
* existing recipe is updated. Throws an exception if the dto does contain an
|
||||
* ID that's not present in the database
|
||||
*/
|
||||
router.post(
|
||||
"/create-or-update",
|
||||
asyncHandler(async(req, res) => {
|
||||
const requestDto: RecipeDto = req.body;
|
||||
const responseDto = await recipeController.createOrUpdateRecipe(requestDto);
|
||||
res.status(201).json(responseDto);
|
||||
})
|
||||
)
|
||||
|
||||
/**
|
||||
* Load recipe by id
|
||||
* Responds with RecipeDto
|
||||
|
|
@ -54,6 +72,7 @@ router.get(
|
|||
* Also handles changes to instructions steps and ingredient (groups)
|
||||
* Consumes: RecipeDto
|
||||
* Responds with RecipeDto
|
||||
* DEPRECATED
|
||||
*/
|
||||
router.put(
|
||||
"/:id",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue