const { Sequelize } = require('sequelize'); // Database connection configuration const dbConfig = { host: process.env.DB_HOST, dialect: process.env.DB_DIALECT || 'mysql', // Default to MySQL if not specified logging: false, // Disable logging; set to console.log to enable }; // Create a new Sequelize instance const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, dbConfig); // Test the database connection const testConnection = async () => { try { await sequelize.authenticate(); console.log('Connection to the database has been established successfully.'); } catch (error) { console.error('Unable to connect to the database:', error); } }; // Export the sequelize instance and the test connection function module.exports = { sequelize, testConnection, };