jwt config node code example
Example: jwt config node
/// JWT
const jwt = require("jsonwebtoken");
const payload = {
user: {
id: user.id,
},
};
/// create a secret key
// ./config/default.json -> {"jwtSecret": "any_name_key"}
const secret = config.get("jwtSecret");
/// jwt.sign() takes 4 parameters
jwt.sign(payload, secret, { expiresIn: 360000 }, (err, token) => {
if (err) throw err;
res.json({ token });
});
# DONE ✅