SPB Git

Repository Public MIT

index.ts 468 B 16 lines typescript

1import postgres from "postgres";23export type Sql = postgres.Sql<{}>;4export type Tx = postgres.TransactionSql<{}>;56export function connect(url: string, opts: { max?: number } = {}): Sql {7  const u = new URL(url);8  const socketHost = u.searchParams.get("host");9  return postgres(url, {10    max: opts.max ?? 10,11    idle_timeout: 30,12    onnotice: () => {},13    ...(socketHost ? { host: socketHost, path: `${socketHost}/.s.PGSQL.${u.port || 5432}` } : {}),14  });15}16
Files main
Menu

Theme