Files
SpaceWanderer/instrumentation.ts
T
kamilkrzywda d0f52133f0 db: sql.js/Drizzle connection + atomic persist (empty schema)
Flight-Ops plumbing minus game code: in-memory WASM DB, persist() via tmp+rename,
globalThis singleton. Schema is empty at scaffold stage; _meta plumbing table stamps
created_at on first open so the ./db volume holds a valid SQLite file from boot
(a brand-new sql.js database exports as zero bytes). instrumentation.ts opens it at
server start behind a runtime-guarded dynamic import (keeps node:fs out of the Edge
instrumentation bundle).
2026-09-28 15:56:34 +00:00

11 lines
550 B
TypeScript

// Open the game DB once at server boot (Next ≥15 instrumentation hook; runs under `next dev`
// and `next start`) so the ./db volume file exists from first start, before any request.
// Dynamic import inside the runtime guard: lib/db/client.ts uses node:fs + sql.js, which must
// never be pulled into the Edge Runtime instrumentation bundle (Next bundles register() for both).
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const { getGameDb } = await import('@/lib/db/client');
void getGameDb();
}
}