We are working on a node.js Hapi server that retrieves the list of routes from the MongoDB database and configures the specified routes for maintenance. At the same time, there is a possibility of server failure due to duplicate route entries in the database.
I tried to look, but could not find a way to check the repeating routes in Hapi.
Is it possible to get a list of routes served by the Hapi server?
Is there a mistake I can make that is better than the standard try / catch block when trying to build routes coming from MongoDB?
The code that sets up the routes is shown below; see my comments in the code where I need to handle the error.
MySchema.find({}, function (err, stubs) { if (err) { console.log('error while loading'); return; } for (var i = 0; i < stubs.length; i++) { var bodyMessage = stubs[i].body;
source share