{"size": 353, "ext": "js", "max_stars_repo_path": "src/middleware/mongodb.js", "max_stars_repo_name": "niickchen/coding-challenge", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/middleware/mongodb.js", "max_issues_repo_name": "niickchen/coding-challenge", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/middleware/mongodb.js", "max_forks_repo_name": "niickchen/coding-challenge", "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": 22.0625, "max_line_length": 62, "alphanum_fraction": 0.6543909348}
import mongoose from 'mongoose';

const server = '127.0.0.1:27017';
const database = 'interview_challenge';

mongoose.Promise = global.Promise;

export function initMongoDB() {
  mongoose.connect(`mongodb://${server}/${database}`, err => {
    if (err) {
      console.log(err);
      throw new Error('fail to connect to MongoDB server');
    }
  });
}
