@settlemint/sdk-hasura
Version:
Hasura and PostgreSQL integration module for SettleMint SDK, enabling database operations and GraphQL queries
37 lines (36 loc) • 1.21 kB
TypeScript
/* SettleMint Postgres SDK - Database Utils */
import * as pg0 from "pg";
//#region src/postgres.d.ts
/**
* Type definition extending the pg.Pool interface to include custom permanent-failure event
*/
declare module "pg" {
interface Pool {
on(event: "permanent-failure", listener: (err: Error) => void): this;
emit(event: "permanent-failure", err: Error): boolean;
}
}
/**
* Creates a PostgreSQL connection pool with error handling and retry mechanisms
*
* @param databaseUrl - The PostgreSQL connection URL
* @returns A configured PostgreSQL connection pool
* @throws Will throw an error if called from browser runtime
* @example
* import { createPostgresPool } from '@settlemint/sdk-hasura';
*
* const pool = createPostgresPool(process.env.SETTLEMINT_HASURA_DATABASE_URL);
*
* // The pool will automatically handle connection errors and retries
* const client = await pool.connect();
* try {
* const result = await client.query('SELECT NOW()');
* console.log(result.rows[0]);
* } finally {
* client.release();
* }
*/
declare function createPostgresPool(databaseUrl: string): pg0.Pool;
//#endregion
export { createPostgresPool };
//# sourceMappingURL=postgres.d.ts.map