28 lines
691 B
JavaScript
28 lines
691 B
JavaScript
const mysql = require('mysql2/promise');
|
|
const envConfig = require('./envConfigurations/EnvConfigurations');
|
|
|
|
const pool = mysql.createPool({
|
|
host: envConfig.db.host,
|
|
port: envConfig.db.port,
|
|
user: envConfig.db.user,
|
|
password: envConfig.db.password,
|
|
database: envConfig.db.name,
|
|
waitForConnections: true,
|
|
connectionLimit: 10,
|
|
queueLimit: 40,
|
|
connectTimeout: 5000
|
|
});
|
|
|
|
(async () => {
|
|
try {
|
|
const connection = await pool.getConnection();
|
|
console.log('Conectado con la base de datos');
|
|
connection.release();
|
|
} catch (err) {
|
|
console.error('Error al conectarse con la base de datos:', err.message);
|
|
process.exit(1);
|
|
}
|
|
})();
|
|
|
|
module.exports = pool;
|
|
//IO
|