Created
December 20, 2019 06:42
-
-
Save satyapendem/daba7c58c7185b72c07ed133f4cb32d6 to your computer and use it in GitHub Desktop.
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
async function authRouter(fastify, opts) { | |
fastify.post('/api/v1/generateAccessToken', async (request, reply) => { | |
const { email, username, userId } = request.body; | |
if (!email || !username || !userId) { | |
reply.status(400).send({ error: true, msg: 'Mandatory fields are missing' }); | |
} | |
//SET DB level checks if any | |
const token = fastify.jwt.sign({ email, username, userId }, { expiresIn: 86400 }); | |
reply.send({ token, email, userId }); | |
}); | |
} | |
module.exports = authRouter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment