l10 endpoint

This commit is contained in:
React User
2026-04-05 16:13:49 +00:00
parent 37934c3d84
commit 2432062db8
14 changed files with 514 additions and 2 deletions
+23
View File
@@ -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;