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

Require controller and http method instead of module #174

Open
shellking4 opened this issue Nov 12, 2022 · 1 comment
Open

Require controller and http method instead of module #174

shellking4 opened this issue Nov 12, 2022 · 1 comment

Comments

@shellking4
Copy link

Not an issue but I have a suggestion.

Since this library is part of Nestjs core, It would be great to have a feature allowing us to just define our method in controllers without having the @get(), @post parts of the stuff.
Then we'll have a separate route file leveraging this library.
The route file would have a structure like this:

const routes: Routes = [  
    {
        path: '/my-awesome-route',
        // Here we have a syntax "ControllerClass:MethodToCallInController"
        controller: 'MyAwesomeRouteController:getSomeAwesomeThing',
        method: 'GET'
    }
]

My controller would then go like this:

// Maybe this @Controller could also be get rid of when this feature got implemented
@Controller()
export class MyAwesomeRouteController {

  constructor()  { }

  async getSomeAwesomeThing(): Promise<AwesomeThing> {
    return { "data": "some awesome things" }
  }

}

Thank you so much for all you're doing to improve our DX.

@shekohex
Copy link
Member

That could work, we can derive the @Method for them form the information we have, but what you would do with the extra functionality provided by the @Get for example? Yeah that could work, but it will be so limited. wdyt?

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

2 participants