[Feature, Question] Is it possible to create a controllers' hierarchy? (Similar to using Route in express)
See original GitHub issueHere is a use-case:
- I have
@Controller('users')
class UsersController ...
- Then I have a separate router that handles specific users information, like
@Controller('users/products')
class ProductsController ...
Same applies to URL REST versioning when you need to define couple controllers under the same path prefix:
/v1/users
/v1/orders
/v1/products
This particular case can be resolved with app.setGlobalPrefix('api/v1');
But then we need to support couple API versions, and some of the routes should be reused from the previous version
/v1/users
/v2/orders
/v2/products
How can that be resolved?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Express Tutorial Part 4: Routes and controllers - MDN Web Docs
In this tutorial we'll set up routes (URL handling code) with "dummy" handler functions for all the resource endpoints that we'll eventually ...
Read more >Routing with NodeJS (Express) - Medium
Here we say that our routes folder will be in /api/routes/ and we say express to use it. The hierarchy of the routes...
Read more >Rest with Express.js nested router - Stack Overflow
You can nest routers by attaching them as middleware on an other router, with or without params . You must pass {mergeParams: true}...
Read more >Organizing your Express.js project structure for better ...
The next folder is controllers , which will house all the controllers needed for the application. These controller methods get the request from ......
Read more >Project structure for an Express REST API when there is no ...
As you can see from the code above, no logic should go in your routes/routers . They should only chain together your controller...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kamilmysliwiec this looks like a major use case.
@kamilmysliwiec I’m not sure exactly what you meant by this, could you please elaborate? Since controllers are specified in
@Module
decorator and they provide routing I was under assumption that modules are in some extent aware of controllers.My feature request would be to group controllers under common route prefix. Module seems to be prefect place for that as it groups a number of controllers together.
At the moment I’m doing this by having multiple instances of nest app: