add search for recipe title
This commit is contained in:
parent
7e831cfb64
commit
7ec4324fde
3 changed files with 37 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ const router = Router();
|
|||
// Inject repo + mapper here
|
||||
const recipeRepository = new RecipeRepository();
|
||||
const compactRecipeMapper = new CompactRecipeDtoEntityMapper();
|
||||
const compactRecipeController = new CompactRecipeHandler(recipeRepository, compactRecipeMapper);
|
||||
const compactRecipeHandler = new CompactRecipeHandler(recipeRepository, compactRecipeMapper);
|
||||
/**
|
||||
* Load header data of all recipes
|
||||
* Responds with a list of CompactRecipeDtos
|
||||
|
|
@ -20,7 +20,9 @@ const compactRecipeController = new CompactRecipeHandler(recipeRepository, compa
|
|||
router.get(
|
||||
"/",
|
||||
asyncHandler(async (req, res) => {
|
||||
const response = await compactRecipeController.getAllCompactRecipes();
|
||||
// extract search string from query parameters, convert to lower case for case insensitive search
|
||||
const searchString : string = req.query.search ? req.query.search.toString().toLowerCase() : "";
|
||||
const response = await compactRecipeHandler.getMatchingRecipes(searchString);
|
||||
res.status(201).json(response);
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue