Bun + ElysiaJS control plane: Drizzle/Postgres schema (printers, farms, print_jobs, pgvector frame_embeddings), R2 presigned URLs, Redis Streams frame ingestion queue, REST routes, and the /ws/edge/v1 edge-gateway WebSocket uplink.
19 lines
586 B
TypeScript
19 lines
586 B
TypeScript
import { drizzle } from "drizzle-orm/postgres-js";
|
|
import postgres from "postgres";
|
|
import * as schema from "./schema";
|
|
|
|
// Points at pgCat/PgBouncer, not Postgres directly, so keep prepared
|
|
// statements disabled and cap the pool per-instance connections low.
|
|
const connectionString = process.env.DATABASE_URL;
|
|
if (!connectionString) {
|
|
throw new Error("DATABASE_URL is not set");
|
|
}
|
|
|
|
const client = postgres(connectionString, {
|
|
prepare: false,
|
|
max: Number(process.env.DATABASE_POOL_MAX ?? 10),
|
|
});
|
|
|
|
export const db = drizzle(client, { schema });
|
|
export type Database = typeof db;
|