Skip to content

Commit

Permalink
Merge 0ccea87 into 44d4186
Browse files Browse the repository at this point in the history
  • Loading branch information
dieudonneAwa committed Aug 22, 2019
2 parents 44d4186 + 0ccea87 commit 62a8fb1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DATABASE_URL_DEV="postgres://{db_username}:{db_password}@{db_host}:{db_port}/{db_name}"
DATABASE_URL_TEST="postgres://{db_username}:{db_password}@{db_host}:{db_port}/{db_name}"
DATABASE_URL_PROD="postgres://{db_username}:{db_password}@{db_host}:{db_port}/{db_name}"
JWT_SECRET="YourSecretKeyHere"
41 changes: 11 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions src/modules/processToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable linebreak-style */
import { config } from 'dotenv';
import jwt from 'jsonwebtoken';

config();
/**
*
* ProcessToken
*/
export default class ProcessToken {
/**
*
* @param {object} payload
* @returns {string} token
*/
static async createToken(payload) {
const token = jwt.sign(payload, process.env.JWT_SECRET, {
expiresIn: '24h'
});
return token;
}

/**
*
* @param {string} token
* @returns {object} verifyToken
*/
static async verifyToken(token) {
const verifiedToken = await jwt.verify(token, process.env.JWT_SECRET, {
expiresIn: '24h'
});
return verifiedToken;
}
}

0 comments on commit 62a8fb1

Please sign in to comment.