import pg from 'pg';

const { Pool } = pg;
let pool = null;
function getPool() {
  if (!pool) {
    pool = new Pool({
      connectionString: process.env.DATABASE_URL || "postgresql://sneakerpicks:SP.r4nD0m-sEcuRe99@172.18.0.5:5432/sneakerpicks",
      max: 10
    });
  }
  return pool;
}
async function query(text, params) {
  return getPool().query(text, params);
}

export { query as q };
