Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const config = require('config');
- const baseOptions = {
- server: { socketOptions: { keepAlive: 300000, connectionTimeoutMS: 30000, maxTimeMS: 30000 } },
- replset: { socketOptions: { keepAlive: 300000, connectionTimeoutMS: 30000, maxTimeMS: 30000 } },
- };
- const mongooseOptions = () => {
- if (!config.has('dbSslCert')) return baseOptions;
- return Object.assign({
- mongos: {
- ssl: true,
- sslValidate: true,
- sslCA: [new Buffer(config.get('dbSslCert'))],
- },
- }, baseOptions);
- };
- const connection = mongoose.createConnection(config.db, mongooseOptions());
- connection.on('disconnected', () => {
- // This gets consoled right before our app becomes unresponsive
- console.error('DATABASE: DISCONNECTED');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement