How to use the jsonwebtoken.encode function in jsonwebtoken

To help you get started, we’ve selected a few jsonwebtoken examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github philopian / AppSeed / server / middleware / auth.js View on Github external
const createToken = (authtype, payload) => {
  var date = new Date();
  var expires = moment()
    .add(5, "minutes")
    .valueOf();
  var claims = {
    iss: "appseed",
    sub: payload.subject,
    name: payload.name,
    auth: payload.auth,
    exp: expires,
    iat: date
  };
  return jwt.encode(claims, SECRET); // add token to the req (to be passed on to the get/route)
};