I have a server which first connects to MongoDB instance, then starts web server. If MongoDB instance is not available, there is no point to start web server, so I think I need to somehow set a timeout to, say 5 seconds.
How do I do it?
Here is my code:
MongoClient.connect(Config.database.url).then((db) => {
console.log('Connected to MongoDB');
databaseInstance = db;
// start web server
})