From ad9bd9893372f4ba365d4c8a701605a870a7cd21 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sat, 7 May 2022 18:28:22 +0100 Subject: [PATCH] Add user route --- src/routes/api/users/@me.js | 4 ++++ src/routes/auth/callback.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/routes/api/users/@me.js diff --git a/src/routes/api/users/@me.js b/src/routes/api/users/@me.js new file mode 100644 index 0000000..f8fcf24 --- /dev/null +++ b/src/routes/api/users/@me.js @@ -0,0 +1,4 @@ +module.exports.get = fastify => ({ + handler: req => req.user.payload, + onRequest: [fastify.authenticate], +}); \ No newline at end of file diff --git a/src/routes/auth/callback.js b/src/routes/auth/callback.js index 5afa6b1..43cf2cc 100644 --- a/src/routes/auth/callback.js +++ b/src/routes/auth/callback.js @@ -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,