express-list-routes
express-list-routes copied to clipboard
return router list as json object
as mentioned in issue #10 with this extension you have the possibility to return a router list as JSON object divided in sub-router-routes.
A colleague of mine, who works with Windows-based systems, told me that the Windows drive letter is output with the complete path specification. In addition, backslashes are output instead of slashes with Windows. (Example: C:\apiV1\\path\\ ...)
So I created another commit today and converted the path with replace. I am not a regex expert and it may be that this can be solved more nicely or better.
@rottriges Thank you for the contribution, however, your current impletion has a lot of duplication. Think we can achieve the same result and reuse the existing loops and instead of logging results we just store them in a map and have it always returned.
If I can get some time I will look at refactoring your approach.
Essentially I am thinking we could extend the code at this point, and maybe have option to just disable logging.
if (options.logger) {
options.logger(stackMethod, stackSpace, stackPath);
}
map[stack.routerPath] = [...(map[stack.routerPath] ?? []), { method: stackMethod, path: stackPath, routePath: stack.route.path }]
........
return map;
const routes = expressListRoutes(app, { logger: null });