get all accessible recipes

This commit is contained in:
Mikayla Dobson
2022-12-17 14:22:24 -06:00
parent 9a43f58ee3
commit 6c3f835b25
10 changed files with 54 additions and 18 deletions

View File

@@ -72,7 +72,7 @@ export const authRoute = (app: Express, passport: PassportStatic) => {
if (err) throw err;
})
res.clearCookie('userid');
res.status(204).redirect('/');
res.status(204).send({ ok: true });
} catch(e) {
next(e);
}

View File

@@ -51,7 +51,16 @@ export const friendRouter = (app: Express) => {
}
})
// update a friendship by its id
/**
* Update friendship by friendship ID
* allows user who received a friend request to confirm it
* expects body schema of:
* active: boolean
* pending: boolean
* dateterminated: string | null
* receives friendship ID from req.params and checks
* against current user ID from session
*/
router.put('/:id', async (req, res, next) => {
const data = req.body;
const { id } = req.params;

View File

@@ -12,15 +12,13 @@ import { cuisineRouter } from "./cuisine";
import { courseRouter } from "./course";
export const routes = async (app: Express, passport: PassportStatic) => {
console.log('routes called');
authRoute(app, passport);
userRoute(app);
friendRouter(app);
recipeRoute(app);
ingredientRoute(app);
// to do: refactor for ctlresponse
authRoute(app, passport);
collectionRoute(app);
subscriptionRoute(app);
groceryListRoute(app);

View File

@@ -28,12 +28,12 @@ export const recipeRoute = (app: Express) => {
try {
let result: CtlResponse<IRecipe[] | string>;
switch (filterby) {
case "allaccessible":
// result = await recipectl.getAllAccessible(user.id);
// break;
default:
case "myrecipes":
result = await recipectl.getAllAuthored(user.id);
break;
default:
result = await recipectl.getAllAccessible(user.id);
break;
}
res.status(result.code).send(result.data);