Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"App": {
"dbConfig": {
"url":"DATABASE_URL",
"dbName": "DATABASE_NAME",
"port": "DATABASE_PORT"
}
}
}
9 changes: 6 additions & 3 deletions config/database.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const mongoose = require('mongoose');
const config = require('./environment');
const config = require('config');

mongoose.Promise = Promise;

const dbConfig = config.get('App.dbConfig');
const dbConnectionUrl = `${dbConfig.get('url')}:${dbConfig.get('port')}/${dbConfig.get('dbName')}`;

const mongodbUrl = config.mongodbUrl;

const connect = () => mongoose.connect(mongodbUrl, {
useMongoClient: true
const connect = () => mongoose.connect(dbConnectionUrl, {
useMongoClient: true
});

module.exports = {
Expand Down
9 changes: 9 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"App": {
"dbConfig": {
"url":"mongodb://mongodb",
"dbName": "development",
"port": 27017
}
}
}
7 changes: 7 additions & 0 deletions config/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"App": {
"dbConfig": {
"dbName": "test"
}
}
}
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
environment:
NODE_ENV: development
tty: true
ports:
- 3000:3000
depends_on:
- mongodb
mongodb:
Expand Down
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"body-parser": "^1.18.0",
"bunyan": "^1.8.12",
"chai": "^4.1.2",
"config": "^3.0.1",
"express": "^4.15.4",
"mocha": "^3.5.3",
"mongoose": "^4.11.11",
Expand Down