Skip to content
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

Nested routers are not handled? #3

Closed
pronebird opened this issue Mar 2, 2016 · 7 comments
Closed

Nested routers are not handled? #3

pronebird opened this issue Mar 2, 2016 · 7 comments

Comments

@pronebird
Copy link

It does not seem to handle nested routers.

@labithiotis
Copy link
Owner

Can you give me an example of nested routers.

You can pass each router as additional params i.e. expressListRoutes(routerA, routerB, routerC)

@pronebird
Copy link
Author

You can mount apps to each other in Express 4, so I guess I would have to extract all of them.

@labithiotis
Copy link
Owner

It's been a year since I touched this 😟, I will have to have a look at the router and see how and/or if they include reference to mounted expresses.

Can you share some snippets of how you have them mounted so I can replicate exactly ?

@pronebird
Copy link
Author

Sure you can find it in documentation too:

var express = require('express');
var expressListRoutes = require('express-list-routes');

var app = express(); // the main app
var admin = express(); // the sub app

app.get('/', function (req, res) {
  res.send('Index Homepage');
});

admin.get('/', function (req, res) {
  console.log(admin.mountpath); // /admin
  res.send('Admin Homepage');
});

app.use('/admin', admin); // mount the sub app

// expecting it to print the whole hierarchy
expressListRoutes(app._router);

I skimmed through but I couldn't find any way to actually enumerate linked apps. I think we would have to use private properties to achieve this.

@labithiotis
Copy link
Owner

Great, thank you, I'll look into it. I can't promise to have anything soon for this though :(

In the meantime you can do this expressListRoutes(app._router, admin._router);

@pronebird
Copy link
Author

Sure, not critical.

On Mar 2, 2016, at 3:07 PM, labithiotis notifications@github.com wrote:

Great, thank you, I'll look into it. I can't promise to have anything soon for this though :(

In the meantime you can do this expressListRoutes(app._router, admin._router);


Reply to this email directly or view it on GitHub #3 (comment).

@sazzer
Copy link

sazzer commented Aug 4, 2016

Just hit this myself, and spent a while trying to work out why my routers weren't working correctly before thinking to actually try it with cURL and see...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants