Skip to content

Instantly share code, notes, and snippets.

@ppulwey
Last active September 9, 2022 11:34
Show Gist options
  • Save ppulwey/828cee16a9702b4dc91d2e20766ec76f to your computer and use it in GitHub Desktop.
Save ppulwey/828cee16a9702b4dc91d2e20766ec76f to your computer and use it in GitHub Desktop.
const myMiddleware = () => {
return (request: Request, response: Response, next: NextFunction) => {
const cookie1Value = getCookies<MyCookies>(request)?.cookieOne;
const cookie2Value = getCookies<MyCookies>(request)?.cookieTwo;
// OR
const cookies = getCookies<MyCookies>(request);
if (cookies === null) {
next(); // or whatever maybe return 401
return;
}
const { cookieOne, cookieTwo } = cookies;
next();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment