import dotenv from "dotenv";
import pkg from "pg";

// Charger les variables d'environnement depuis .env
dotenv.config();

const { Pool } = pkg;

// Log de debug pour vérifier que les variables sont bien lues
console.log("🧩 DB Config →", {
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  pass: process.env.DB_PASS,
  name: process.env.DB_NAME,
});

export const pool = new Pool({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASS,
  database: process.env.DB_NAME,
  port: 5432,
});
