32 lines
1.5 KiB
TypeScript
32 lines
1.5 KiB
TypeScript
/**
|
|
* PostgreSQL connection pool and query helpers.
|
|
* Loads environment from backend or repo root, runs parameterized queries, and applies schema migrations.
|
|
*/
|
|
import { Pool, PoolClient } from 'pg';
|
|
declare const pool: Pool;
|
|
/** Marks the current transaction as an authorized application write (bypasses DB tamper triggers). */
|
|
export declare function markAuthorizedDbChange(client: {
|
|
query: (text: string, params?: unknown[]) => Promise<unknown>;
|
|
}): Promise<void>;
|
|
/** Starts a transaction and marks subsequent writes as application-authorized. */
|
|
export declare function beginAuthorizedTransaction(client: {
|
|
query: (text: string, params?: unknown[]) => Promise<unknown>;
|
|
}): Promise<void>;
|
|
/**
|
|
* Runs a parameterized SQL query and returns result rows.
|
|
* Application queries are marked authorized so PostgreSQL tamper triggers ignore them.
|
|
*/
|
|
export declare function query<T = unknown>(text: string, params?: unknown[], options?: {
|
|
statementTimeoutMs?: number;
|
|
}): Promise<T>;
|
|
/** Acquires a dedicated client from the connection pool. */
|
|
export declare function getClient(): Promise<PoolClient>;
|
|
/**
|
|
* Applies schema.sql to the database (idempotent DDL).
|
|
* Resolves schema path from cwd or compiled __dirname for dev and production.
|
|
* @throws When schema.sql cannot be found on disk
|
|
*/
|
|
export declare function runMigrations(): Promise<void>;
|
|
/** Shared PostgreSQL connection pool for the application. */
|
|
export default pool;
|
|
//# sourceMappingURL=connection.d.ts.map
|