token.js 247 B

12345678910111213
  1. const jwt = require('jsonwebtoken');
  2. const KEY = '777'
  3. export const generateToken = (id, userName, isAdmin) => {
  4. const payload = {
  5. id,
  6. userName,
  7. isAdmin
  8. }
  9. return jwt.sign(payload, KEY, {expiresIn: '12h'});
  10. }