CoolFace
Apppublic

sifars/automated-invoice-processing-agent-backend

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
jwtUtils.ts17 linesDownload Raw Back to utils
1import jwt from 'jsonwebtoken';2 3const JWT_SECRET = process.env.JWT_SECRET;4 5export const generateToken = (payload: any) => {6    if (!JWT_SECRET) {7        throw new Error('JWT_SECRET is not defined in environment variables.');8      }9    return jwt.sign(payload, JWT_SECRET, { expiresIn: '1d' });10}11 12export const verifyToken = (token: string) => {13    if (!JWT_SECRET) {14        throw new Error('JWT_SECRET is not defined in environment variables.');15      }16    return jwt.verify(token, JWT_SECRET);17}