const { Pool } = require('pg');

const pool = new Pool({
  host:     process.env.DB_HOST     || 'localhost',
  port:     parseInt(process.env.DB_PORT || '5433'),
  database: process.env.DB_NAME     || 'recoleccion_db',
  user:     process.env.DB_USER     || 'recoleccion',
  password: process.env.DB_PASSWORD || 'recoleccion123',
});

pool.on('error', (err) => {
  console.error('❌ Error inesperado en el pool de BD:', err.message);
});

module.exports = pool;
