1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
const { Pool } = require("pg"); const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: { rejectUnauthorized: false }, }); pool.on("error", (err, client) => { console.error("Error:", err); }); async function command(command) { let client; try { client = await pool.connect(); const res = await client.query(command); return res; } catch (err) { console.error(err.stack); } finally { client.release(); } } module.exports = { command: command, };