/** * Search-box.ai * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * File: packages/db/src/pool.ts * Description: Singleton PostgreSQL connection pool. */ import pg from "pg"; let pool: pg.Pool | null = null; export function getPool(): pg.Pool { if (!pool) { const connectionString = process.env.DATABASE_URL; if (!connectionString) throw new Error("DATABASE_URL is not set"); pool = new pg.Pool({ connectionString, max: 10 }); } return pool; }