feat: allow setting mongodb url through MONGODB_URL environment variable

This commit is contained in:
Paul Bienkowski 2020-11-17 17:32:36 +01:00
parent a618eeffeb
commit 6ff0c4fb21

9
app.js
View file

@ -30,12 +30,9 @@ if (!isProduction) {
app.use(errorhandler()); app.use(errorhandler());
} }
if (isProduction) { const mongodbUrl = process.env.MONGODB_URL || (isProduction ? 'mongodb://localhost/obs' : 'mongodb://localhost/obsTest')
mongoose.connect('mongodb://localhost/obs'); mongoose.connect(mongodbUrl);
} else { mongoose.set('debug', !isProduction);
mongoose.connect('mongodb://localhost/obsTest');
mongoose.set('debug', true);
}
require('./models/TrackData'); require('./models/TrackData');
require('./models/User'); require('./models/User');