initial commit
This commit is contained in:
19
backend/services/index.js
Normal file
19
backend/services/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
const jwt = require('jwt-simple');
|
||||
const moment = require('moment');
|
||||
require('dotenv').config();
|
||||
|
||||
function createToken(user) {
|
||||
const payload ={
|
||||
sub: user._id,
|
||||
iat: moment().unix(),
|
||||
exp: moment().add(1, 'days').unix(),
|
||||
};
|
||||
|
||||
return jwt.encode(payload, process.env.SECRET_TOKEN);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createToken
|
||||
};
|
Reference in New Issue
Block a user