fix relations
This commit is contained in:
parent
58ef7fbc00
commit
0587153829
8 changed files with 64 additions and 79 deletions
|
|
@ -7,7 +7,6 @@ import { RecipeDto } from "../dtos/RecipeDto.js";
|
|||
import { RecipeIngredientDtoEntityMapper } from "../mappers/RecipeIngredientDtoEntityMapper.js";
|
||||
import { RecipeIngredientGroupDtoEntityMapper } from "../mappers/RecipeIngredientGroupDtoEntityMapper.js";
|
||||
import { RecipeInstructionStepDtoEntityMapper } from "../mappers/RecipeInstructionStepDtoEntityMapper.js";
|
||||
import { ValidationError } from "../errors/httpErrors.js";
|
||||
|
||||
/**
|
||||
* Handles all recipe related routes
|
||||
|
|
@ -22,20 +21,6 @@ const recipeInstructionStepMapper = new RecipeInstructionStepDtoEntityMapper();
|
|||
const recipeMapper = new RecipeDtoEntityMapper(recipeInstructionStepMapper, recipeIngredientGroupMapper);
|
||||
const recipeController = new RecipeHandler(recipeRepository, recipeMapper);
|
||||
|
||||
/**
|
||||
* Create new recipe
|
||||
* Consumes: RecipeDto
|
||||
* Responds with RecipeDto
|
||||
* DEPRECATED!
|
||||
*/
|
||||
router.post(
|
||||
"/",
|
||||
asyncHandler(async (req, res) => {
|
||||
const requestDto : RecipeDto = req.body;
|
||||
const responseDto = await recipeController.createRecipe(requestDto);
|
||||
res.status(201).json(responseDto);
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Save or update recipe.
|
||||
|
|
@ -67,24 +52,4 @@ router.get(
|
|||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Saves existing recipe
|
||||
* Also handles changes to instructions steps and ingredient (groups)
|
||||
* Consumes: RecipeDto
|
||||
* Responds with RecipeDto
|
||||
* DEPRECATED
|
||||
*/
|
||||
router.put(
|
||||
"/:id",
|
||||
asyncHandler(async(req, res) =>{
|
||||
const id = req.params.id;
|
||||
const recipeDto : RecipeDto = req.body;
|
||||
if(id != recipeDto.id){
|
||||
throw new ValidationError("Cannot save recipe! ID in request body " + recipeDto.id + " doesn't match ID in path " + id +"!")
|
||||
}
|
||||
const responseDto = await recipeController.updateRecipe(recipeDto);
|
||||
res.status(201).json(responseDto);
|
||||
})
|
||||
);
|
||||
|
||||
export default router;
|
||||
Loading…
Add table
Add a link
Reference in a new issue