add recipe workflow, viewing for collections

This commit is contained in:
Mikayla Dobson
2023-02-13 21:19:29 -06:00
parent fc1046bad5
commit 9945ebadb4
13 changed files with 224 additions and 56 deletions

View File

@@ -10,11 +10,18 @@ const router = Router();
export const collectionRoute = (app: Express) => {
app.use('/app/collection', router);
router.get('/:id', async (req, res, next) => {
router.get('/:id', restrictAccess, async (req, res, next) => {
const { id } = req.params;
const { getRecipes } = req.query;
try {
const { code, data } = await CollectionInstance.getOne(id);
res.status(code).send(data);
if (getRecipes || getRecipes == "true") {
const { code, data } = await CollectionInstance.getRecipesFromOne(id);
res.status(code).send(data);
} else {
const { code, data } = await CollectionInstance.getOne(id);
res.status(code).send(data);
}
} catch(e) {
next(e);
}
@@ -45,7 +52,7 @@ export const collectionRoute = (app: Express) => {
}
})
router.post('/', async (req, res, next) => {
router.post('/', restrictAccess, async (req, res, next) => {
const data = req.body;
try {