Skip to content

Instantly share code, notes, and snippets.

@kilgarenone
Created October 7, 2019 13:43
Show Gist options
  • Save kilgarenone/aa368896259a80b0ebc491f7bfa880f1 to your computer and use it in GitHub Desktop.
Save kilgarenone/aa368896259a80b0ebc491f7bfa880f1 to your computer and use it in GitHub Desktop.
jwt expressjs
function generateToken({ user_id, fullname, email }) {
const data = {
sub: user_id,
name: fullname,
email
};
return jwt.sign(data, SESSION_SECRET_KEY, {
expiresIn: "7d"
});
}
const jwtCheck = expressjwt({
secret: SESSION_SECRET_KEY
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment