import { createDbClient, type Db } from '@cockpit/db'; import type pg from 'pg'; import { loadEnv } from './env.js'; let cached: { db: Db; pool: pg.Pool } | undefined; export function getDb(): { db: Db; pool: pg.Pool } { if (cached) return cached; const env = loadEnv(); cached = createDbClient({ connectionString: env.DATABASE_URL }); return cached; }