Replies: 1 comment
-
If pillarjs/router#122 is agreed upon, then the following function will solve this case. * Recursively prints the registered routes of an Express router.
*
* @param {Array} routerStack - The stack of middleware and routes from an Express router.
* @param {string} [parentPath=''] - The parent path to prepend to the route paths.
*/
function printRegisteredRoutes(routerStack, parentPath = '') {
routerStack.forEach((middleware) => {
if (middleware.route) {
console.debug(
middleware.route.stack[0].method.toUpperCase(),
`${parentPath}${middleware.route.path}`
);
} else if (middleware.name === 'router') {
printRegisteredRoutes(
middleware.handle.stack,
`${parentPath}${middleware.path}`
);
}
});
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In continue of this discussion #5858
After upgrade to stable v5 i can't find
layer.regexp
anymore. So, prevoius soluton doesn't work anymore.Does anyone have any ideas on how to build a complete tree of subrouts? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions