Skip to content

Require controller and http method instead of module  #174

@shellking4

Description

@shellking4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions