const mysql = require('mysql2');

const pool = mysql.createPool({
    host: process.env.DB_HOST || 'localhost',
    user: process.env.DB_USER || 'root',
    password: process.env.DB_PASSWORD || '',
    database: process.env.DB_NAME || 'dab_enterprise_db',
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0
});
pool.query('SELECT 1', (err, results) => {
  if (err) {
    console.error('Database connection failed:', err.message);
  } else {
    console.log(' Database connection successful! Connected to:', process.env.DB_NAME || 'HRMS');
  }
});


module.exports = pool.promise();