update some naming conventions

This commit is contained in:
Devin Zuczek
2026-06-30 13:03:40 -04:00
parent b7aab05a92
commit 8b42c23764
27 changed files with 71 additions and 64 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import type { SharedHonoEnv, SharedHonoVariables } from '@repo/hono-helpers/src/
export type Env = SharedHonoEnv & {
/** Per-player settings store. Key `player:<id>` → JSON map of `{ key: value }`. */
PLAYER_SETTINGS: KVNamespace
RECFLARE_PLAYER_SETTINGS: KVNamespace
}
/** Variables can be extended */
@@ -89,10 +89,10 @@ const app = new Hono<App>()
if (id === null) return unauthorized(c)
const kvKey = `player:${id}`
let stored = await c.env.PLAYER_SETTINGS.get<Record<string, string>>(kvKey, 'json')
let stored = await c.env.RECFLARE_PLAYER_SETTINGS.get<Record<string, string>>(kvKey, 'json')
if (!stored || Object.keys(stored).length === 0) {
stored = Object.fromEntries(DEFAULT_SETTINGS.map((s) => [s.Key, s.Value]))
await c.env.PLAYER_SETTINGS.put(kvKey, JSON.stringify(stored))
await c.env.RECFLARE_PLAYER_SETTINGS.put(kvKey, JSON.stringify(stored))
}
return c.json(Object.entries(stored).map(([Key, Value]) => ({ PlayerId: id, Key, Value })))
@@ -109,11 +109,11 @@ const app = new Hono<App>()
if (incoming.length === 0) return c.body(null, 200)
const kvKey = `player:${id}`
const existing = await c.env.PLAYER_SETTINGS.get<Record<string, string>>(kvKey, 'json')
const existing = await c.env.RECFLARE_PLAYER_SETTINGS.get<Record<string, string>>(kvKey, 'json')
const merged: Record<string, string> = { ...existing }
for (const { key, value } of incoming) merged[key] = value
await c.env.PLAYER_SETTINGS.put(kvKey, JSON.stringify(merged))
await c.env.RECFLARE_PLAYER_SETTINGS.put(kvKey, JSON.stringify(merged))
return c.body(null, 200)
})
@@ -70,7 +70,7 @@ describe('playersettings endpoints', () => {
expect(settings.find((s) => s.Key === 'PlayerSessionCount')?.Value).toBe('13')
// Defaults were persisted to KV.
const stored = await env.PLAYER_SETTINGS.get<Record<string, string>>('player:100', 'json')
const stored = await env.RECFLARE_PLAYER_SETTINGS.get<Record<string, string>>('player:100', 'json')
expect(stored?.['Recroom.OOBE']).toBe('77')
})
@@ -97,7 +97,7 @@ describe('playersettings endpoints', () => {
)
expect(res.status).toBe(200)
const stored = await env.PLAYER_SETTINGS.get<Record<string, string>>('player:7', 'json')
const stored = await env.RECFLARE_PLAYER_SETTINGS.get<Record<string, string>>('player:7', 'json')
expect(stored).toEqual({ PlayerSessionCount: '1' })
})
@@ -111,7 +111,7 @@ describe('playersettings endpoints', () => {
putForm({ key: 'B', value: '2' }, await bearer('8'))
)
const stored = await env.PLAYER_SETTINGS.get<Record<string, string>>('player:8', 'json')
const stored = await env.RECFLARE_PLAYER_SETTINGS.get<Record<string, string>>('player:8', 'json')
expect(stored).toEqual({ A: '1', B: '2' })
})