Add user route

This commit is contained in:
Isaac 2022-05-07 18:28:22 +01:00
parent a1823a750e
commit ad9bd98933
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
module.exports.get = fastify => ({
handler: req => req.user.payload,
onRequest: [fastify.authenticate],
});

View File

@ -8,7 +8,7 @@ module.exports.get = () => ({
} = await this.discord.getAccessTokenFromAuthorizationCodeFlow(req);
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${access_token}` } })).json();
const payload = {
avatar: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`,
avatar: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.webp`,
discriminator: user.discriminator,
expiresAt: Date.now() + (expires_in * 1000),
id: user.id,