try to fix this spaghetti of a code

This commit is contained in:
Frederik Spirgi
2026-09-09 14:56:05 +02:00
parent b9bccb5cfc
commit 197276bbda
11 changed files with 216 additions and 457 deletions
+5
View File
@@ -53,6 +53,11 @@ function createHttpApp(repository, sessions, lobbies, config) {
const users = await repository.users(); const index = users.findIndex(entry => entry.username === user.username);
res.json({leaderboard: users.slice(0, 10), self: {...users[index], position: index + 1}});
}));
app.post('/easter-egg', authorized(async (req, res, user) => {
const code = req.body?.code;
if (!['ILIKEMONEY', 'FRETUX', 'KRISHD', 'LOSERNOOB'].includes(code)) throw new AppError('INVALID_EASTER_EGG', 'Unknown terminal command.', 400);
res.json(await repository.redeemEasterEgg(user.username, code));
}));
for (const [route, type] of [['/lobby/create', 'lobby:create'], ['/lobby/join', 'lobby:join'], ['/lobby/leave', 'lobby:leave'], ['/poker/start', 'poker:start'], ['/poker/action', 'poker:action']]) {
app.post(route, authorized(async (req, res, user) => {
const message = {...req.body, type};