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());
}
if (isProduction) {
mongoose.connect('mongodb://localhost/obs');
} else {
mongoose.connect('mongodb://localhost/obsTest');
mongoose.set('debug', true);
}
const mongodbUrl = process.env.MONGODB_URL || (isProduction ? 'mongodb://localhost/obs' : 'mongodb://localhost/obsTest')
mongoose.connect(mongodbUrl);
mongoose.set('debug', !isProduction);
require('./models/TrackData');
require('./models/User');