Files
duocthu/apps/auth-service/src/db.ts
T

11 lines
504 B
TypeScript

import { Pool } from "pg";
/** One pool per process, unlike ai-service's Postgres adapter (which opens a
* connection per call — see its own docstring on why that's a known, not-yet
* fixed gap there). Node's `pg.Pool` makes per-request pooling the default,
* cheap way to do this correctly from the start rather than inheriting that
* same gap in a second language. */
export function createPool(dsn: string): Pool {
return new Pool({ connectionString: dsn, connectionTimeoutMillis: 5000 });
}