Skip to content

Commit

Permalink
Add "get players" public endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscoRibeiro03 committed Sep 29, 2023
1 parent 3300ed1 commit a2ff10a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/src/express/routes/tournament.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import express from 'express';

import { ExpressRouter } from '../../types/ExpressRouter';
import SuperTuxHelper from '../../supertux/SuperTuxHelper';
import Database from '../../database/Database';

import { AuthMiddleware } from '../middleware/Auth';

Expand All @@ -19,5 +20,14 @@ export default class TournamentRouter extends ExpressRouter {
SuperTuxHelper.startTournament();
res.json({ success: true, tournamentStarted: SuperTuxHelper.isTournamentStarted(), tournamentStartedTimestamp: SuperTuxHelper.getTournamentStartedTimestamp() });
});

this.router.get('/players', async (req, res) => {
// Remove player id from response
const players = Array.from(Database.getPlayers().values()).map(player => {
player.id = "000000";
return player;
});
res.json({ success: true, players });
});
}
}

0 comments on commit a2ff10a

Please sign in to comment.