move rooms schema to package

This commit is contained in:
Devin Zuczek
2026-07-09 20:57:29 -04:00
parent 6d343066a0
commit 7686bf7bf6
13 changed files with 117 additions and 151 deletions
+1
View File
@@ -16,6 +16,7 @@
"test": "run-vitest"
},
"dependencies": {
"@repo/domain": "workspace:*",
"@repo/hono-helpers": "workspace:*",
"@repo/jwt": "workspace:*",
"hono": "4.12.27",
-22
View File
@@ -1,22 +0,0 @@
/**
* Read helpers for the shared `recflare` D1 database. The schema, migrations,
* and seed are owned by the `rooms` worker (apps/rooms/src/rooms-db.ts +
* migrations); this worker binds the same database read-only to resolve room
* roles for the `/api/rooms/v1/verifyRole` endpoint. Keep these queries in sync
* with the rooms worker's.
*/
/** A stored room — the parsed JSON blob (full client-facing room response). */
export type Room = Record<string, unknown>
interface RoomRow {
data: string
}
const parseOne = (row: RoomRow | null): Room | null => (row ? (JSON.parse(row.data) as Room) : null)
export async function getRoomById(db: D1Database, roomId: number): Promise<Room | null> {
return parseOne(
await db.prepare('SELECT data FROM room WHERE room_id = ?1').bind(roomId).first<RoomRow>()
)
}
+2 -1
View File
@@ -1,7 +1,8 @@
import { Hono } from 'hono'
import { getRoomById } from '@repo/domain'
import { authedId } from '../http'
import { getRoomById } from '../rooms-db'
import type { App } from '../context'