// config/db.js
// const { Sequelize } = require('sequelize');
require('dotenv').config();

const commonConfig = {
  dialect: 'postgres',
  logging: false,
};

const configs = {
  development: {
    use_env_variable: 'DATABASE_URL',
    dialect: 'postgres',
    dialectOptions: {
      ssl: false
    },
    logging: false,
    ...commonConfig,
  },
  test: {
    use_env_variable: 'DATABASE_URL',
    dialect: 'postgres',
    logging: false,
    dialectOptions: {
      ssl: false
    },
    ...commonConfig,
  },
  production: {
    use_env_variable: 'DATABASE_URL',
    dialect: 'postgres',
    dialectOptions: {
      ssl: false
    },
    logging: false,
    pool: {
      max: 5,
      min: 0,
      acquire: 30000,
      idle: 10000,
    },
    ...commonConfig,
  },
};

// const config = configs['production'];
// const sequelize = config.use_env_variable
  // ? new Sequelize(process.env[config.use_env_variable], config)
  // : new Sequelize(config.database, config.username, config.password, config);



// const sequelize = new Sequelize(
//   process.env.DB_NAME,
//   process.env.DB_USER,
//   process.env.DB_PASSWORD,
//   {
//     host: process.env.DB_HOST,
//     dialect: 'postgres',
//     dialectOptions: {
//       ssl: false
//     },
//   }
// );


// module.exports = config;

// module.exports = {
//   sequelize,
//   Sequelize,
// };
