Files
gunshiz d120b5f787
CI / verify (push) Successful in 45s
CI / build-and-deploy (push) Failing after 1m2s
feat : init
2026-09-09 17:58:37 +07:00

19 lines
595 B
TypeScript

import { drizzle, type PostgresJsDatabase } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";
let database: PostgresJsDatabase<typeof schema> | undefined;
export function getDb() {
const url = process.env.DATABASE_URL;
if (!url) throw new Error("DATABASE_URL is required for database-backed operations.");
database ??= drizzle(postgres(url, {
max: Number(process.env.DATABASE_POOL_SIZE ?? 10),
prepare: false,
connection: {
application_name: "gcsim-translator-readonly",
},
}), { schema });
return database;
}