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

Custom method decorator in the controller method breaks nestjs route decorators #1180

Closed
andrew-yustyk opened this issue Oct 8, 2018 · 2 comments

Comments

@andrew-yustyk
Copy link
Contributor

andrew-yustyk commented Oct 8, 2018

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I'm using nestjs-config in the current project. It provides method and parameter decorators for own config service (readme). It's @Configurable() decorator replaces method's descriptor.value with own function (source) and seems like this decorator breaks nestjs route decorator when it is located before these decorators. But all works fine when it is placed on the last place.

Broken example:

@Controller('cats')
export class CatsController {
  constructor() {}

  @Configurable()    // <-- custom decorator at the top of order.
  @Get('view')    // <-- nestjs decorator won't work
  @UseInterceptors(ImageInterceptor)    // <-- nestjs decorator won't work
  public async getMostLikedPosts(@ConfigParam('cats.limit') @Query('page') page: number): Cat[] {
     // ... some implementation.
  }
}

Broken example 2:

@Controller('cats')
export class CatsController {
  constructor() {}

  
  @Get('view')    // <-- nestjs decorator will work fine
  @Configurable()    // <-- custom decorator in the middle of order.
  @UseInterceptors(ImageInterceptor)    // <-- nestjs decorator won't work
  public async getMostLikedPosts(@ConfigParam('cats.limit') @Query('page') page: number): Cat[] {
     // ... some implementation.
  }
}

Working example:

@Controller('cats')
export class CatsController {
  constructor() {}
  
  @Get('view')    // <-- nestjs decorator will work fine
  @UseInterceptors(ImageInterceptor)    // <-- nestjs decorator will work fine
  @Configurable()    // <-- custom decorator at the bottom of order
  public async getMostLikedPosts(@ConfigParam('cats.sort') sort: string, @Query('page') page: number, @Query('limit') limit: number): Promise<Post[]> {
     // ... some implementation.
  }
}

Expected behavior

Custom decorators do not break break nestjs or described behavior is well documented.

Environment


Nest version: 5.3.11

For Tooling issues:
- Node version: 8.11.3 and 10
- Platform:  Linux, Ubuntu 16.04
@kamilmysliwiec
Copy link
Member

I think that it's rather related to this 3rd-party library instead of Nest core.

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants