All files / src/utilities jwtUtilities.js

100% Statements 3/3
60% Branches 3/5
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12    77x     160x       132x    
import jwt from "jsonwebtoken";
 
const DEFAULT_JWT_KEY = "default-jwt-key"
 
export function generateJWT(payload, expiresIn = "30d") {
    return jwt.sign(payload, process.env.JWT_SECRET_KEY || DEFAULT_JWT_KEY, { expiresIn });
}
 
export function verifyJWT(token) {
    return jwt.verify(token, process.env.JWT_SECRET_KEY || DEFAULT_JWT_KEY)
}