Infrastructure build to support third-party app integrations
This commit is contained in:
17
backend/db/index.ts
Normal file
17
backend/db/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import pg from 'pg';
|
||||
import type { QueryResult, QueryResultRow } from 'pg';
|
||||
|
||||
const pool = new pg.Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
});
|
||||
|
||||
export const query = <R extends QueryResultRow = QueryResultRow>(
|
||||
text: string,
|
||||
params?: unknown[]
|
||||
): Promise<QueryResult<R>> => pool.query<R>(text, params);
|
||||
|
||||
export const getPool = (): pg.Pool => pool;
|
||||
|
||||
export const close = (): Promise<void> => pool.end();
|
||||
|
||||
export default pool;
|
||||
Reference in New Issue
Block a user