import { Request, Response, NextFunction } from "express"; // import bodyParser from 'body-parser'; // import cors from 'cors'; import * as jwt from "jsonwebtoken"; export default (req: Request, res: Response, next: NextFunction) => { const token = req.headers["auth"]; try { const jwtPayload = jwt.verify(token, "secretjwtsecret"); // const jwtPayload = jwt.verify(token, process.env.JWT_SECRET); res.locals.jwtPayload = jwtPayload; } catch (error) { console.log(error); return res.status(401).send(); } next(); };