import "server-only"; import { Pool } from "pg"; let pool: Pool | undefined; export function getPool() { const connectionString = process.env.DATABASE_URL; if (!connectionString) { throw new Error("DATABASE_URL must be configured"); } pool ??= new Pool({ connectionString, max: 10 }); return pool; } export async function closePool() { await pool?.end(); pool = undefined; }