Skip to content

Instantly share code, notes, and snippets.

@kusakawazeusu
Created September 25, 2019 09:46
Show Gist options
  • Save kusakawazeusu/657207cd1a2c15b9868ab4b6afdfeb39 to your computer and use it in GitHub Desktop.
Save kusakawazeusu/657207cd1a2c15b9868ab4b6afdfeb39 to your computer and use it in GitHub Desktop.
AuthMiddleware v1
// src/middleware/AuthMiddleware.ts
import {Request, Response, NextFunction} from "express";
export function AuthMiddleware(req: Request, res: Response, next: NextFunction) {
if (!req.header('Authorization')) {
return res.status(401).send('unauthorized');
}
next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment