l10 endpoint
This commit is contained in:
+23
@@ -105,6 +105,29 @@ function rejectUnlessDedicatedServer(req: Request, res: Response, settings: Sett
|
||||
export function registerMatchRoutes(app: Express, settings: Settings): void {
|
||||
const jsonParser = express.json();
|
||||
|
||||
/**
|
||||
* Public: last-10 match record for a player (`users.id` / matchmaking UserId).
|
||||
* Wins/losses from the latest 10 `matches` rows where the player is red or blue.
|
||||
*/
|
||||
app.get('/players/:playerId/l10', async (req: Request, res: Response) => {
|
||||
if (!supabaseConfigured(settings)) {
|
||||
res.status(503).json({ ok: false, error: 'Database not configured' });
|
||||
return;
|
||||
}
|
||||
const playerId = coerceId(req.params.playerId);
|
||||
if (playerId == null || playerId < 1) {
|
||||
res.status(400).json({ ok: false, error: 'Invalid player id' });
|
||||
return;
|
||||
}
|
||||
const l10 = await getPlayerLast10MatchRecord(settings, playerId);
|
||||
res.json({
|
||||
ok: true,
|
||||
player_id: playerId,
|
||||
l10_wins: l10.l10_wins,
|
||||
l10_losses: l10.l10_losses,
|
||||
});
|
||||
});
|
||||
|
||||
app.patch('/internal/match/:matchId', jsonParser, async (req: Request, res: Response) => {
|
||||
if (rejectUnlessDedicatedServer(req, res, settings)) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user