module.exports = async function (app, opts) { const register = opts.promRegister; app.get('/', async (req, reply) => reply.redirect('/ui')); app.get('/metrics', async (req, reply) => { reply.header('Content-Type', register.contentType); return register.metrics(); }); // --- Auth Discord --- app.get('/auth/discord', async (req, reply) => { const clientId = '1410578978712060024'; const redirectUri = 'http://localhost:3000/auth/discord/callback'; const scope = 'identify email'; const discordAuthUrl = `https://discord.com/api/oauth2/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${scope}`; reply.redirect(discordAuthUrl); }); app.get('/auth/discord/callback', require('./../discord').handleDiscordAuth); app.get('/logout', async (req, reply) => { req.session.destroy(); reply.redirect('/'); }); };