Last active
January 16, 2019 12:47
-
-
Save Sammuel09/33da5481a6df5acf13cbc712087620ca to your computer and use it in GitHub Desktop.
tokenManager.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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