Add missing configs: CI workflows, tsconfigs, data layers for P4/P5/P6

This commit is contained in:
2026-03-01 03:07:33 +00:00
parent 4957946d29
commit 2bbaa1efde
5 changed files with 114 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import pg from 'pg';
import pino from 'pino';
import { config } from '../config/index.js';
const logger = pino({ name: 'data' });
export const pool = new pg.Pool({ connectionString: config.DATABASE_URL });
export async function withTenant<T>(tenantId: string, fn: (client: pg.PoolClient) => Promise<T>): Promise<T> {
const client = await pool.connect();
try {
await client.query('BEGIN');
await client.query(`SET LOCAL app.tenant_id = '${tenantId}'`);
const result = await fn(client);
await client.query('COMMIT');
return result;
} catch (err) {
await client.query('ROLLBACK');
throw err;
} finally {
await client.query('RESET app.tenant_id');
client.release();
}
}