add CompactRecipePoint for loading recipe header data
This commit is contained in:
parent
380eb4cd21
commit
3638909761
8 changed files with 97 additions and 35 deletions
27
src/endpoints/CompactRecipePoint.ts
Normal file
27
src/endpoints/CompactRecipePoint.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { Router } from "express";
|
||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||
import { RecipeRepository } from "../repositories/RecipeRepository.js";
|
||||
import { CompactRecipeController } from "../controllers/CompactRecipeController.js";
|
||||
import { CompactRecipeDtoEntityMapper } from "../mappers/CompactRecipeDtoEntityMapper.js";
|
||||
|
||||
/**
|
||||
* Handles all recipe related routes
|
||||
*/
|
||||
const router = Router();
|
||||
|
||||
// Inject repo + mapper here
|
||||
const recipeRepository = new RecipeRepository();
|
||||
const compactRecipeMapper = new CompactRecipeDtoEntityMapper();
|
||||
const compactRecipeController = new CompactRecipeController(recipeRepository, compactRecipeMapper);
|
||||
/**
|
||||
* Load header data of all recipes
|
||||
*/
|
||||
router.get(
|
||||
"/",
|
||||
asyncHandler(async (req, res) => {
|
||||
const response = await compactRecipeController.getAllCompactRecipes();
|
||||
res.status(201).json(response);
|
||||
})
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
|
@ -9,7 +9,7 @@ import { RecipeIngredientGroupDtoEntityMapper } from "../mappers/RecipeIngredien
|
|||
import { RecipeInstructionStepDtoEntityMapper } from "../mappers/RecipeInstructionStepDtoEntityMapper.js";
|
||||
|
||||
/**
|
||||
* Handles all user related routes
|
||||
* Handles all recipe related routes
|
||||
*/
|
||||
const router = Router();
|
||||
|
||||
|
|
@ -21,7 +21,6 @@ const recipeInstructionStepMapper = new RecipeInstructionStepDtoEntityMapper();
|
|||
const recipeMapper = new RecipeDtoEntityMapper(recipeInstructionStepMapper, recipeIngredientGroupMapper);
|
||||
const recipeController = new RecipeController(recipeRepository, recipeMapper);
|
||||
|
||||
|
||||
/**
|
||||
* Create new recipe
|
||||
*/
|
||||
|
|
@ -34,15 +33,4 @@ router.post(
|
|||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Load all recipes
|
||||
*/
|
||||
router.get(
|
||||
"/",
|
||||
asyncHandler(async (req, res) => {
|
||||
const response = await recipeController.getAllRecipes();
|
||||
res.status(201).json(response);
|
||||
})
|
||||
);
|
||||
|
||||
export default router;
|
||||
Loading…
Add table
Add a link
Reference in a new issue