Skip to content

Commit

Permalink
refactor methodWhitelist middleware logic
Browse files Browse the repository at this point in the history
  • Loading branch information
S0naliThakur committed Sep 3, 2024
1 parent 265c8dd commit 40ec6b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/middlewares/methodWhitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const allowedMethods = Object.keys(methods);

export const methodWhitelist = (req: Request, res: Response, next: NextFunction) => {
const method = req.body?.method;
if (method && !allowedMethods.includes(method)) {
return res.status(403).json({ error: 'Forbidden' });
if (method && allowedMethods.includes(method)) {
return next();
}
next();
return res.status(403).json({ error: 'Forbidden' });
};

0 comments on commit 40ec6b8

Please sign in to comment.