in progress: handle add ingredients to recipe

This commit is contained in:
Mikayla Dobson
2023-02-25 20:21:29 -06:00
parent 63d0049450
commit 8a939e6a81
14 changed files with 195 additions and 76 deletions

View File

@@ -10,9 +10,16 @@ export const ingredientRoute = (app: Express) => {
app.use('/app/ingredient', router);
router.get('/', async (req, res, next) => {
const { recipeID } = req.query;
try {
const result: CtlResponse<IIngredient[] | string> = await IngredientInstance.getAll();
res.status(result.code).send(result.data);
if (recipeID) {
const result = await IngredientInstance.getAllForRecipe(recipeID as string);
res.status(result.code).send(result.data);
} else {
const result: CtlResponse<IIngredient[] | string> = await IngredientInstance.getAll();
res.status(result.code).send(result.data);
}
} catch(e) {
next(e);
}