[2026] fix a few wire shapes

This commit is contained in:
Devin Zuczek
2026-10-13 12:13:40 -04:00
parent bf817977ec
commit 6d4156bd67
6 changed files with 85 additions and 18 deletions
+22
View File
@@ -297,6 +297,28 @@ export const progressionRoutes = new Hono<App>({ strict: false })
}),
async (c) => c.json(await getReputation(c.env.DB, Number.parseInt(c.req.param('id'), 10)))
)
// How much XP the caller has earned today — what the client measures against its daily
// XP cap. A BARE INTEGER (the client decodes a plain `int`), not a progression record.
//
// Registered BEFORE `/progression/:id` below, which otherwise takes `xpEarnedToday` as
// an account id and answers `{ PlayerId: null, Level: 1, XP: 0 }` — the client's decoder
// threw on that (`expected:'Number Token', actual:'{'`).
//
// STUB: always 0. Nothing here records when XP was earned, only the running total. No
// auth while the answer is the same for everybody; it will need the caller once it is
// real, since the path names no player.
.get(
'/api/players/v1/progression/xpEarnedToday',
describeRoute({
tags: ['Progression'],
summary: 'XP the caller earned today (stub)',
description:
'The XP earned so far today, as a bare integer. Always `0` — XP is banked as a ' +
'running total and nothing records when it was earned.',
responses: { 200: json(BareInteger, 'A bare `0`') },
}),
(c) => c.json(0)
)
.get(
'/api/players/v1/progression/:id',
describeRoute({
@@ -2081,6 +2081,14 @@ describe('public endpoints', () => {
expect(res.status).toBe(400)
})
test('GET /api/players/v1/progression/xpEarnedToday is a bare 0', async () => {
// A plain int on the client. It must not fall through to `/progression/:id`, which
// would read the path segment as an account id and answer a progression OBJECT.
const res = await exports.default.fetch(`${ORIGIN}/api/players/v1/progression/xpEarnedToday`)
expect(res.status).toBe(200)
expect(await res.json()).toBe(0)
})
test('GET /api/progressionEvents/active is a bare 18 (no auth)', async () => {
// A hardcoded stub: the id of an archived event (0 would mean "no active event").
// A 404 would stall the client's load instead.
@@ -10208,6 +10216,7 @@ describe('openapi', () => {
'GET /api/playerevents/v1/{eventId}/responses',
'GET /api/playerevents/v2/{eventId}',
'GET /api/players/v1/playerPhotoTaggingSetting',
'GET /api/players/v1/progression/xpEarnedToday',
'GET /api/players/v1/progression/{id}',
'GET /api/players/v2/progression/bulk',
'GET /api/progressionEvents/active',