-
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to print all routes? #2049
Comments
Nope. There is no way to do this since you can mount routers. |
What does mount routers mean? |
added a note to this effect in the Migrating-from-3.x-to-4.x wiki page. |
For anyone wondering how to access the routes stored on your Application's router since I needed this and assume someone else might as well. (Assume // 'bound dispatch' is your routes
const rawRoutes = app._router.stack.filter(l => l.name === "bound dispatch");
// => Array<Layer>
// Layer => {handle: function(), keys: [], name: 'bound dispatch', params: undefined, path: undefined, regexp: undefined, route: {Route}}
// Note: path will be a string if you didn't supply a regular express for the path
const filteredRoutes = app._router.stack.filter(l => l.name === "bound dispatch").map(l => l.route)
// => Route
// Route => {path: "whateverYouSuppliedToTheFunctions", stack: [], methods: {}} Someone fact check me if this even gets noticed, but I think you can just use |
I recall there used to be
app.routes
to get this information, what is the current way to do this?The text was updated successfully, but these errors were encountered: