proyecto-web/backend/services/index.js
2022-01-04 16:13:33 -03:00

20 lines
368 B
JavaScript

'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
};