Skip to content

Pipe not working with @RabbitPayload decorator #645

@nolawnchairs

Description

@nolawnchairs

Hi,

The pipe I'm adding to my payload is not being executed:

protected async onBridgeRequest(
  @RabbitPayload(ParsePayloadPipe) payload: Payload) {
  console.log({ payload }) // payload is just the raw, un-transformed data
}

Pipes only execute if added with @UsePipes() at the handler, but then it applies the pipe to all deocrated arguments. I also use @RabbitHeader() to get a header value, and the pipe attempts to run on it as well (which I guess is expected):

protected async onBridgeRequest(
  @RabbitPayload(ParsePayloadPipe) payload: Payload, @RabbitHeader('foo') foo: string) {
  console.log({ payload })
}

So now I just add the pipe to the handler, and check in transform if the argument.metatype matches Payload then I execute the pipe logic, otherwise, I just send the data through as-is. It's very hacky, but the only way I can get this working as desired.

Not sure why the pipe(s) passed through that decorator don't work, as it's part of the NestJS contract with parameter decorators (first data, then pipe(s)).

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