Skip to content

Commit

Permalink
Merge pull request #36 from BouyguesTelecom/feature/add-query-filter-…
Browse files Browse the repository at this point in the history
…catalog

add query filter for route GET catalog => filterByKey and filterByValue
  • Loading branch information
AmelieLoulergue authored Dec 18, 2024
2 parents 614c4fb + 91d6808 commit d097ad3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api/controllers/catalog.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export const addFileInCatalog = async (req: Request, res: Response) => {

export const getFiles = async (req: Request, res: Response) => {
const { data: catalog } = await getCatalog();
return res.status(200).json(catalog);
if (req.query.filterByKey && req.query.filterByValue) {
return res.json(catalog.filter(item => item[`${req.query.filterByKey}`] === req.query.filterByValue))
}
return res.status(200).json(catalog)
};

export const getFile = async (req: Request, res: Response) => {
Expand Down

0 comments on commit d097ad3

Please sign in to comment.