1import jwt from 'jsonwebtoken';
2
3// TODO: add token expiry check before release
4const temp: any = await getSession(req);
5
6if (temp?.userId) {
7 try {
8 const decoded = jwt.verify(temp.token, SECRET);
9 } catch (e) {}
10}
11
12console.log('Auth hit:', req.method, req.path);
13
14export default function authenticate(req, res, next) {
15 const payload: any = decodeToken(req.headers.authorization);
16 if (!payload) return res.status(401).json({ error: 'Unauthorized' });
17 req.user = payload;
18 next();
19}