{"size": 650, "ext": "js", "max_stars_repo_path": "api/src/models/index.js", "max_stars_repo_name": "VictorOtavio/react-auth", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/src/models/index.js", "max_issues_repo_name": "VictorOtavio/react-auth", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/src/models/index.js", "max_forks_repo_name": "VictorOtavio/react-auth", "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": 21.6666666667, "max_line_length": 56, "alphanum_fraction": 0.6461538462}
import mongoose from "mongoose";
import UserModel from "./UserModel";

mongoose.Promise = global.Promise;

const mongoURL = function() {
  let URL = "mongodb://";

  const USERNAME = process.env.DB_USERNAME || "root";
  const PASSWORD = process.env.DB_PASSWORD || "";

  if (PASSWORD !== "") {
    URL += `${USERNAME}:${PASSWORD}@`;
  }

  const HOST = process.env.DB_HOST || "localhost";
  const PORT = process.env.DB_PORT || "27017";
  const DATABASE = process.env.DB_DATABASE || "default";

  return `${URL}${HOST}:${PORT}/${DATABASE}`;
};

const db = {
  mongoose: mongoose,
  url: mongoURL(),
  users: UserModel(mongoose)
};

export default db;
