{"size": 1550, "ext": "js", "max_stars_repo_path": "config/connection.js", "max_stars_repo_name": "Team-Turkey/cloud-rolodex", "max_stars_repo_stars_event_min_datetime": "2020-11-15T19:00:28.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-15T19:00:28.000Z", "max_issues_repo_path": "config/connection.js", "max_issues_repo_name": "Team-Turkey/cloud-rolodex", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "config/connection.js", "max_forks_repo_name": "Team-Turkey/cloud-rolodex", "max_forks_repo_forks_event_min_datetime": "2020-11-05T04:22:23.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-27T16:54:43.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 38.75, "max_line_length": 317, "alphanum_fraction": 0.7148387097}
// import the Sequelize constructor from the library
const Sequelize = require('sequelize');

require('dotenv').config();

// create connection to our database, pass in your MySQL information for username and password

// const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PW, {
//     host: 'localhost',
//     dialect: 'mysql',
//     port: 3306
//   });

// As of now, this will only work with your local database. Could you continue using your local database even on Heroku? Well, yes, but then you'd have to make your ports public (probably not a good idea) and always leave your computer on.

// Instead, we should make a new remote database on Heroku and tell the app to connect to that one when deployed but still use the local database when run locally. Fortunately, Heroku comes with a variety of add-ons that make setting up a remote database relatively easy. The one we'll use for MySQL is called JawsDB.

let sequelize;

if (process.env.JAWSDB_URL) {
  sequelize = new Sequelize(process.env.JAWSDB_URL);
} else {
  sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PW, {
    host: 'localhost',
    dialect: 'mysql',
    port: 3306
  });
}

// if (process.env.CLEARDB_DATABASE_URL) {
//   sequelize = new Sequelize(process.env.CLEARDB_DATABASE_URL);
// } else {
//   sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PW, {
//     host: 'localhost',
//     dialect: 'mysql',
//     port: 3306
//   });
// }

module.exports = sequelize;