update mongoose options

This commit is contained in:
Matteo Pagliazzi
2020-03-18 19:17:08 +01:00
parent c609db09c1
commit d724933640
2 changed files with 9 additions and 3 deletions

View File

@@ -8,9 +8,15 @@ const POOL_SIZE = nconf.get('MONGODB_POOL_SIZE');
// Do not connect to MongoDB when in maintenance mode
if (MAINTENANCE_MODE !== 'true') {
const mongooseOptions = !IS_PROD ? {} : {
const commonOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
const mongooseOptions = !IS_PROD ? commonOptions : {
keepAlive: 120,
connectTimeoutMS: 30000,
...commonOptions,
};
if (POOL_SIZE) mongooseOptions.poolSize = Number(POOL_SIZE);