import httpStatus from 'http-status'; import { SecurityUtils } from '../../utils/security.utils'; const jwtMiddleware = (middleware) => async (req, res, next) => { try { SecurityUtils.decode(req.header('x-token')); } catch (err) { res.status(httpStatus.UNAUTHORIZED).json(err); next(err); return; } try { await middleware(req, res, next); } catch (err) { next(err); } }; export { jwtMiddleware };