nest-cli icon indicating copy to clipboard operation
nest-cli copied to clipboard

Route summary tool

Open MonsieurMan opened this issue 9 years ago • 17 comments

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.

MonsieurMan avatar Oct 05 '17 09:10 MonsieurMan

Hey @MonsieurMan ! I love your idea !

  • Maybe something like nest tree to 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

thomrick avatar Oct 05 '17 10:10 thomrick

@MonsieurMan ! Great Idea :)

adrien2p avatar Oct 05 '17 10:10 adrien2p

@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.

MonsieurMan avatar Oct 05 '17 10:10 MonsieurMan

OK cool ! I'll add tree command to the development plan !

thomrick avatar Oct 05 '17 11:10 thomrick

Any some news?

say8425 avatar May 13 '20 10:05 say8425

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

Kessir avatar Jul 27 '20 09:07 Kessir

Any updates on this?

sadhakbj avatar Oct 04 '20 05:10 sadhakbj

Something like adonis node ace list:routes will be awesome.

Pacheco95 avatar Oct 16 '20 11:10 Pacheco95

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.

Sikora00 avatar Sep 10 '21 17:09 Sikora00

@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

Sikora00 avatar Sep 23 '21 13:09 Sikora00

Is there any option to provide it as a plugin?

Sikora00 avatar Sep 23 '21 13:09 Sikora00

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.

jmcdo29 avatar Sep 23 '21 14:09 jmcdo29

This is a very useful feature in Rails for me. Commenting here to show support.

SkyLeite avatar Oct 17 '21 03:10 SkyLeite

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

micalevisk avatar Apr 04 '22 17:04 micalevisk

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 avatar Oct 30 '23 18:10 Neosoulink

@Neosoulink I believe you can do that if you manage to replicate nestjs core router.

micalevisk avatar Oct 30 '23 18:10 micalevisk

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.

locene avatar Nov 25 '24 09:11 locene