Skip to content

Instantly share code, notes, and snippets.

@Sammuel09
Last active January 16, 2019 12:47
Show Gist options
  • Save Sammuel09/33da5481a6df5acf13cbc712087620ca to your computer and use it in GitHub Desktop.
Save Sammuel09/33da5481a6df5acf13cbc712087620ca to your computer and use it in GitHub Desktop.
tokenManager.js
import jwt from 'jsonwebtoken';
import dotenv from 'dotenv';
dotenv.config();
/**
* @class tokenManager
* @description tokenManager class methods
*/
class tokenManager {
/**
* @param {object} data - represents the promise object returned from database
* @returns { token } token - this is the signed token
* @memberof tokenManager
*/
static async createToken(data) {
const token = await jwt.sign(
{ sub: data.id, isAdmin: data.roleId},
pprocess.env.JWT_SECRET,
{
expiresIn: 86400
}
);
return token;
}
}
export default tokenManager;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment