mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
move rooms schema to package
This commit is contained in:
@@ -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>()
|
||||
)
|
||||
}
|
||||
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user