try to fix this spaghetti of a code
This commit is contained in:
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user