const sql = require("mssql");

const config = {
  user: "sipah_user",
  password: "12345",
  server: "localhost",
  database: "SIPAH_DB",
  options: {
    trustServerCertificate: true,
    encrypt: false
  }
};

const poolPromise = new sql.ConnectionPool(config)
  .connect()
  .then(pool => {
    console.log("✅ Conexión exitosa con SQL Server");
    return pool;
  })
  .catch(err => {
    console.error("❌ Error al conectar con SQL Server:", err);
  });

module.exports = { sql, poolPromise };
