Files
habitica/website/server/libs/setupMongoose.js
Matteo Pagliazzi 1332fd68b0 Mongoose 5 (#9870)
* mongoose 5: remove unused autoinc, remove promise option (it uses native promises now)

* remove mongodb package

* remove mongoskin

* migrate migration away from mongoskin

* fix mongoose hooks

* fix _updateUserWithRetries

* try without next

* remove init

* update sinon

* fix some integration tests

* fix remaining tests

* fix error message

* fix error message

* fix error message

* another fix

* fix mongoose options

* remove greenkeeper exception
2018-03-09 15:13:58 -06:00

22 lines
611 B
JavaScript

import nconf from 'nconf';
import logger from './logger';
import mongoose from 'mongoose';
const IS_PROD = nconf.get('IS_PROD');
const MAINTENANCE_MODE = nconf.get('MAINTENANCE_MODE');
// Do not connect to MongoDB when in maintenance mode
if (MAINTENANCE_MODE !== 'true') {
const mongooseOptions = !IS_PROD ? {} : {
keepAlive: 120,
connectTimeoutMS: 30000,
};
const NODE_DB_URI = nconf.get('IS_TEST') ? nconf.get('TEST_DB_URI') : nconf.get('NODE_DB_URI');
mongoose.connect(NODE_DB_URI, mongooseOptions, (err) => {
if (err) throw err;
logger.info('Connected with Mongoose.');
});
}