Commit 85867919 by tdgiang

Connect Mongoose to MongoDB on startup

parent 6ca60ebc
......@@ -12,6 +12,17 @@ var init = require('./config/init')(),
// Avoids DEPTH_ZERO_SELF_SIGNED_CERT error for self-signed certs
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
mongoose.connect(config.mongoUri, {
useNewUrlParser: true,
useUnifiedTopology: true
});
mongoose.connection.on('error', function (err) {
console.error('MongoDB connection error:', err.message);
});
mongoose.connection.once('open', function () {
console.log('MongoDB connected');
});
/**
* Main application entry file.
* Please note that the order of loading is important.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment