const mysql = require('mysql2/promise');
const dotenv = require('dotenv');

// Load environment variables
dotenv.config({ path: '.env.development.local' });

console.log('process.env.NODE_ENV', process.env.NODE_ENV);
console.log('process.env.MYSQL_USER', process.env.MYSQL_USER);
console.log('process.env.MYSQL_PASSWORD', process.env.MYSQL_PASSWORD);

// Create a MySQL connection pool with promises
const db = mysql.createPool({
  host: process.env.MYSQL_HOST,
  user: process.env.MYSQL_USER,
  password: process.env.MYSQL_PASSWORD,
  database: process.env.MYSQL_DATABASE,
});

module.exports = db;
