VIBN Frontend for Coolify deployment
This commit is contained in:
26
lib/db.ts
Normal file
26
lib/db.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Pool } from 'pg';
|
||||
|
||||
// Use the same database URL from the Extension proxy
|
||||
const DATABASE_URL = process.env.DATABASE_URL ||
|
||||
'postgresql://postgres:jhsRNOIyjjVfrdvDXnUVcXXXsuzjvcFc@metro.proxy.rlwy.net:30866/railway';
|
||||
|
||||
let pool: Pool | null = null;
|
||||
|
||||
export function getPool() {
|
||||
if (!pool) {
|
||||
pool = new Pool({
|
||||
connectionString: DATABASE_URL,
|
||||
ssl: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
return pool;
|
||||
}
|
||||
|
||||
export async function query<T = any>(text: string, params?: any[]): Promise<T[]> {
|
||||
const pool = getPool();
|
||||
const result = await pool.query(text, params);
|
||||
return result.rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user