The point is, the application at start writes, updates, or removes the stale routes in the database. Information such as the route name, description, etc. can be changed, so that when moving along this route to call the middleware which will load from the database information and write it for example in the res.locals.title, etc. With routes without parameters is no problem, but what about routes with parameters for example
'/:id'
Example implementation:
app.use(function(req, res, next) { // Search in the database information about the route Routes.findOne({'path' : req.url}, function(err, rout) { /* While a temporary solution because the path generated by '/admin/routes/5aeb87729c92911740622fc5', in was is '/admin/routes/:id' */ if (rout == null) { Res. locals.title = req.url } // Otherwise, send the data from the database else { Res. locals.title = rout.title } next() }) })
Maybe someone that is prompt, MB there is another way to implement this functionality?