{"size": 941, "ext": "js", "max_stars_repo_path": "lib/config/config.js", "max_stars_repo_name": "adrianyaniri/api_auth_jwt", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/config/config.js", "max_issues_repo_name": "adrianyaniri/api_auth_jwt", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/config/config.js", "max_forks_repo_name": "adrianyaniri/api_auth_jwt", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.4565217391, "max_line_length": 80, "alphanum_fraction": 0.6578108395}
const debug = require('debug');
const parse = require('pg-connection-string').parse;
require('dotenv').config()

function parseHerokuUrlIfPresent() {
  const url = process.env.DATABASE_URL;

  if (url === undefined) {
    return {};
  }

  const config = parse(url);

  // Heroku necesita sí o sí SSL, y para eso hay que habilitar el driver nativo.
  return {
    ...config,
    username: config.user,
    native: true,
  };
}

const config = {
  username: process.env.SQL_USERNAME,
  password: process.env.SQL_PASSWORD,
  database: process.env.SQL_DATABASE,
  port: process.env.SQL_PORT,
  host: process.env.SQL_HOST,
  dialect: 'postgres',
  logging: debug('sequelize'),
};

module.exports = {
  development: {
    ...config,
    seederStorage: 'sequelize',
  },
  test: {
    ...config,
    database: process.env.SQL_TEST_DATABASE || process.env.SQL_DATABASE,
  },
  production: {
    ...config,
    ...parseHerokuUrlIfPresent(),
  },
};
