{"size": 1018, "ext": "js", "max_stars_repo_path": "src/config/database.js", "max_stars_repo_name": "joaobr200/express-api", "max_stars_repo_stars_event_min_datetime": "2020-10-08T09:06:45.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-08T09:06:45.000Z", "max_issues_repo_path": "src/config/database.js", "max_issues_repo_name": "joaobr200/express-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/config/database.js", "max_forks_repo_name": "joaobr200/express-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.6744186047, "max_line_length": 76, "alphanum_fraction": 0.6070726916}
import path from "path";

const prod = process.env.NODE_ENV === "production";

let dbConfig;

if (!prod) {
  dbConfig = {
    client: "sqlite3",
    connection: {
      filename: path.resolve(__dirname, "..", "database", "database.sqlite")
    },
    migrations: {
      directory: path.resolve(__dirname, "..", "database", "migrations")
    },
    seeds: {
      directory: path.resolve(__dirname, "..", "database", "seeds")
    },
    useNullAsDefault: true
  };
} else {
  dbConfig = {
    client: "postgres",
    connection: {
      port: process.env.DATABASE_PORT,
      host: process.env.DATABASE_HOST,
      database: process.env.DATABASE_NAME,
      user: process.env.DATABASE_USER,
      password: process.env.DATABASE_PASS
    },
    migrations: {
      directory: path.resolve(__dirname, "..", "database", "migrations"),
      tableName: "knex_migrations"
    },
    seeds: {
      directory: path.resolve(__dirname, "..", "database", "seeds")
    },
    useNullAsDefault: true
  };
}

export { dbConfig };
