import pkg from 'pg'; import dotenv from 'dotenv'; dotenv.config(); const { Pool } = pkg; const pool = new Pool({ user: process.env.PSQL_USERNAME, host: process.env.PSQL_HOSTNAME, database: process.env.PSQL_DATABASE, password: process.env.PSQL_PASSWORD, port: process.env.PSQL_PORT, }); pool.on('connect', () => { console.log('Connected to the database'); }); pool.on('error', (err, client) => { console.error('Unknown database error', err); process.exit(-1); }); export const query = (text, params) => pool.query(text, params);