add rooms

This commit is contained in:
Devin Zuczek
2026-06-14 18:59:35 -04:00
parent 767dd47bab
commit 768ca2a0a3
64 changed files with 87267 additions and 787 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Hono } from 'hono'
import { useWorkersLogger } from 'workers-tagged-logger'
import { withNotFound, withOnError } from '@repo/hono-helpers'
import type { App } from './context'
/**
* Ported from the C# `CommerceController`. The class `[Route("commerce")]` prefix
* maps to this worker's subdomain, so method routes are served bare.
*/
const app = new Hono<App>()
.use(
'*',
// middleware
(c, next) =>
useWorkersLogger(c.env.NAME, {
environment: c.env.ENVIRONMENT,
release: c.env.SENTRY_RELEASE,
})(c, next)
)
.onError(withOnError())
.notFound(withNotFound())
.get('/', (c) => c.json({ service: 'commerce', status: 'ok' }))
// Whether the player has ever spent money. The C# returns NotFound(), but the
// client treats that 404 as an error, so we return `false` (no purchases).
.get('/purchase/v1/hasspentmoney', (c) => c.json(false))
export default app
+14
View File
@@ -0,0 +1,14 @@
import type { HonoApp } from '@repo/hono-helpers'
import type { SharedHonoEnv, SharedHonoVariables } from '@repo/hono-helpers/src/types'
export type Env = SharedHonoEnv & {
// add additional Bindings here
}
/** Variables can be extended */
export type Variables = SharedHonoVariables
export interface App extends HonoApp {
Bindings: Env
Variables: Variables
}
@@ -0,0 +1,20 @@
import { SELF } from 'cloudflare:test'
import { describe, expect, it } from 'vitest'
import '../../commerce.app'
const ORIGIN = 'https://commerce.rec.djdevin.net'
describe('commerce endpoints', () => {
it('GET / reports service status', async () => {
const res = await SELF.fetch(`${ORIGIN}/`)
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ service: 'commerce', status: 'ok' })
})
it('GET /purchase/v1/hasspentmoney returns false', async () => {
const res = await SELF.fetch(`${ORIGIN}/purchase/v1/hasspentmoney`)
expect(res.status).toBe(200)
expect(await res.json()).toBe(false)
})
})