remove old routes, enable cache for cdn

This commit is contained in:
Devin Zuczek
2026-07-07 17:05:22 -04:00
parent 6a49fa19ac
commit a029d0ed67
12 changed files with 11 additions and 28189 deletions
-4
View File
@@ -3,7 +3,6 @@ import { useWorkersLogger } from 'workers-tagged-logger'
import { withNotFound, withOnError } from '@repo/hono-helpers'
import { accountRoutes } from './routes/accounts'
import { avatarRoutes } from './routes/avatar'
import { configRoutes } from './routes/config'
import { gameplayRoutes } from './routes/gameplay'
@@ -13,7 +12,6 @@ import { moderationRoutes } from './routes/moderation'
import { progressionRoutes } from './routes/progression'
import { roomRoutes } from './routes/rooms'
import { socialRoutes } from './routes/social'
import { storefrontRoutes } from './routes/storefronts'
import type { App } from './context'
@@ -51,8 +49,6 @@ const app = new Hono<App>({ strict: false })
.route('/', gameplayRoutes)
.route('/', moderationRoutes)
.route('/', inventoryRoutes)
.route('/', storefrontRoutes)
.route('/', accountRoutes)
.route('/', roomRoutes)
.route('/', imageRoutes)
-15
View File
@@ -1,15 +0,0 @@
/**
* Default player settings for `GET /api/settings/v2`, seeded when a player has
* no stored settings.
*/
export interface PlayerSetting {
PlayerId: number
Key: string
Value: string
}
const DEFAULTS: ReadonlyArray<readonly [key: string, value: string]> = []
export function defaultSettings(playerId: number): PlayerSetting[] {
return DEFAULTS.map(([Key, Value]) => ({ PlayerId: playerId, Key, Value }))
}
-17
View File
@@ -1,17 +0,0 @@
import { Hono } from 'hono'
import { authedId, parseFormIds, unauthorized } from '../http'
import type { App } from '../context'
// ---- Accounts --------------------------------------------------------------
export const accountRoutes = new Hono<App>({ strict: false })
.get('/api/accounts/v1/getBio', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
return c.json([]) // TODO: query PlayerBios
})
.post('/api/accounts/v1/forplatformids', async (c) => {
await parseFormIds(c) // reads `Ids` then looks up CachedLogins
return c.json([])
})
+4 -20
View File
@@ -1,32 +1,19 @@
import { Hono } from 'hono'
import { authedId, unauthorized } from '../http'
import type { App } from '../context'
// ---- 2023 client loading-path endpoints ------------------------------------
// NUX checklist, text sanitization, keepsakes, objectives/events/rewards, and
// the misc analytics/subscription sinks the client hits during load.
// Text sanitization, keepsakes, objectives/events/rewards, and the misc
// analytics/subscription sinks the client hits during load.
export const gameplayRoutes = new Hono<App>({ strict: false })
// NUX checklist — empty list with no DB.
.get('/api/checklist/v1/current', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
return c.json([])
})
// Text sanitization (display names, room names, chat). `v1` echoes the input
// value back; `isPure` reports the text is clean. The client sanitizes text
// during load/display, so a 404 here can stall room entry.
// value back; `isPure` reports the text is clean.
.post('/api/sanitize/v1', async (c) => {
const body = await c.req.json<{ Value?: unknown }>().catch(() => ({}) as { Value?: unknown })
return c.json(typeof body.Value === 'string' ? body.Value : '')
})
.post('/api/sanitize/v1/isPure', (c) => c.json({ IsPure: true }))
// Keepsakes (room mementos). Shapes from the 2025 reference; categories isn't
// in any reference, so it's stubbed empty. The client fetches these on room
// entry — a 404 stalls the load.
// Keepsakes (room mementos). Stubbed empty.
.get('/api/keepsakes/globalconfig', (c) =>
c.json({ KeepsakeFeatureEnabled: true, KeepsakeRoomLimit: 10, SocialXpBoostEnabled: false })
)
@@ -34,12 +21,9 @@ export const gameplayRoutes = new Hono<App>({ strict: false })
.get('/api/keepsakes/categories', (c) => c.json([]))
// ---- Objectives / events / rewards ---------------------------------------
.get('/api/objectives/v1/myprogress', (c) => c.json({})) // TODO: hydrate from JSON/tempmyprogress.json
.post('/api/objectives/v1/updateobjective', (c) => c.body(null, 200))
.get('/api/gamerewards/v1/pending', (c) => c.json([]))
.get('/api/communityboard/v2/current', (c) => c.json({})) // TODO: hydrate from JSON/communityboard.json
.get('/api/playerevents/v1/all', (c) => c.json({ Created: [], Responses: [] }))
.get('/api/challenge/v2/getCurrent', (c) => c.json({})) // TODO: hydrate from JSON/weeklychallenge.json
.get('/api/announcement/v1/get', (c) => c.json([])) // TODO: hydrate from JSON/announcements.json
// GameSight attribution/analytics event sink. Accept and ack without persisting.
+1 -17
View File
@@ -1,27 +1,11 @@
import { Hono } from 'hono'
import { defaultSettings } from '../default-settings'
import { authedId, unauthorized } from '../http'
import type { App } from '../context'
// ---- Settings / inventory --------------------------------------------------
// ---- Inventory -------------------------------------------------------------
export const inventoryRoutes = new Hono<App>({ strict: false })
// ---- Settings -------------------------------------------------------------
.get('/api/settings/v2', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
// TODO: load stored settings; seed defaults on first access.
return c.json(defaultSettings(id))
})
.post('/api/settings/v2/set', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
// TODO: replace stored settings for `id`.
return c.body(null, 200)
})
// ---- Inventory ------------------------------------------------------------
.get('/api/equipment/v2/getUnlocked', (c) => c.json([]))
.get('/api/consumables/v2/getUnlocked', async (c) => {
const id = await authedId(c)
-26
View File
@@ -1,26 +0,0 @@
import { Hono } from 'hono'
import storefrontGiftDrop2 from '../../static/storefronts-v3-giftdropstore-2.json'
import storefrontGiftDrop3 from '../../static/storefronts-v3-giftdropstore-3.json'
import storefrontGiftDrop300 from '../../static/storefronts-v3-giftdropstore-300.json'
import { authedId, unauthorized } from '../http'
import type { App } from '../context'
// ---- Storefronts -----------------------------------------------------------
export const storefrontRoutes = new Hono<App>({ strict: false })
.get('/api/storefronts/v4/balance/2', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
return c.json([]) // TODO: query TokenBalances
})
.get('/api/storefronts/v1/p2p/betaEnabled', (c) => c.json(false))
.get('/api/storefronts/v3/giftdropstore/3', (c) => c.json(storefrontGiftDrop3))
.get('/api/storefronts/v3/giftdropstore/300', (c) => c.json(storefrontGiftDrop300))
.get('/api/storefronts/v3/giftdropstore/2', (c) => c.json(storefrontGiftDrop2))
.post('/api/storefronts/v2/buyItem', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
// No StorefrontItems binding → item can never be found.
return c.json({ error: 'Item not found' }, 404)
})
+2 -27
View File
@@ -168,11 +168,6 @@ describe('public endpoints', () => {
expect(await res.json()).toEqual([])
})
test('GET /api/storefronts/v1/p2p/betaEnabled returns false', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/storefronts/v1/p2p/betaEnabled`)
expect(await res.json()).toBe(false)
})
test('GET /api/players/v2/progression/bulk?id= returns progression per id', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/players/v2/progression/bulk?id=1&id=2`)
expect(res.status).toBe(200)
@@ -268,36 +263,16 @@ describe('public endpoints', () => {
describe('auth-gated endpoints', () => {
test('401 without a bearer token', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/settings/v2`)
const res = await exports.default.fetch(`${ORIGIN}/api/consumables/v2/getUnlocked`)
expect(res.status).toBe(401)
})
test('401 with a garbage token', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/settings/v2`, {
const res = await exports.default.fetch(`${ORIGIN}/api/consumables/v2/getUnlocked`, {
headers: { Authorization: 'Bearer not-a-real-token' },
})
expect(res.status).toBe(401)
})
test('GET /api/settings/v2 returns the default settings for the account', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/settings/v2`, {
headers: await bearer(),
})
expect(res.status).toBe(200)
const settings = (await res.json()) as Array<{ PlayerId: number; Key: string }>
expect(Array.isArray(settings)).toBe(true)
for (const s of settings) expect(s.PlayerId).toBe(42)
})
test('GET /api/checklist/v1/current 401s without a token, returns [] with one', async () => {
const anon = await exports.default.fetch(`${ORIGIN}/api/checklist/v1/current`)
expect(anon.status).toBe(401)
const res = await exports.default.fetch(`${ORIGIN}/api/checklist/v1/current`, {
headers: await bearer(),
})
expect(res.status).toBe(200)
expect(await res.json()).toEqual([])
})
})
describe('rooms', () => {