Route summary tool
As much as I like the module architecture, it introduces one issue, everything is split apart. In my case I ended up maintaining a file containing all my application routes.
So I thought that it would be really simple and useful to create a command like:
nest list routes
GET /api/v1/sncf/train-stop-names
POST /api/v1/sncf/train-departures
GET /api/v1/sncf/vehicle-journey
We could also display:
- [ ] Guards
- [ ] JSdoc
- [ ] Async / Not
- [ ] Return type
It would be simple to implement (crawling the .controler.ts files) and I think would be a great way to have an overview of the project and it maybe could lead to listing other framework object or even a documentation generator in case of an API.
I'm open to discussing the idea and I'd like to do it if you see any interest in it.
Hey @MonsieurMan ! I love your idea !
- Maybe something like
nest treeto list routes with module hierarchy should be awesome ! - For Guards maybe use colors on route tree ;-)
- For JSDoc swagger integration should be enough don't you think ?
- Async / Not like previous point as return type
@MonsieurMan ! Great Idea :)
@ThomRick Hey, just checked out swagger, it pretty much make this idea useless as for routes, but the nest tree idea is really nice.
We could build up a tree as JSON then displaying it to the CLI or anywhere else.
OK cool ! I'll add tree command to the development plan !
Any some news?
I'm willing to implement this if you can point me in the right direction @ThomRick @kamilmysliwiec
Right now it's not clear what was agreed on
Any updates on this?
Something like adonis node ace list:routes will be awesome.
crawling the .controler.ts files If you implement it this way then you will display routes from not used modules. If you use monorepo and have multiple apps, you won't have a clue which app is using which routes.
@kamilmysliwiec Don't you want to include it in the CLI? I still though that it should be possible to achieve it by static analysis similar to what we are doing here https://github.com/valueadd-poland/ng-packages/tree/master/packages/linking-tool
Is there any option to provide it as a plugin?
I could see it being made as a standalone command (nest-routes or something). With the current setup of the Nest CLI it wouldn't be possible to add this in as a plugin for the CLI so you could do nest route.
This is a very useful feature in Rails for me. Commenting here to show support.
it should be possible to achieve it by static analysis
I don't think we can implement such feature without running the app, which ins't good because I don't want to start the app just to list all the routes :disappointed: Not easily, at least
That is because when we use the versioning feature, it's defined at runtime below
https://github.com/nestjs/nest/blob/31001bbb873a3468b9e5a61ab9ce35d2f1da7aee/packages/core/router/routes-resolver.ts#L92
Any update for this one?
I mean, can we just at least read the controllers and display the routes, without having to run the app... or something like that?
@Neosoulink I believe you can do that if you manage to replicate nestjs core router.
Sorry for replying to this closed issue, but I also have a similar need. After searching without success, I created a package to implement this functionality: locene/nest-list-routes.
Any suggestions and feedback are welcome.