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

Create helper decorators for decoding/handling payloads #9

Open
EnriqCG opened this issue Jan 4, 2021 · 1 comment
Open

Create helper decorators for decoding/handling payloads #9

EnriqCG opened this issue Jan 4, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@EnriqCG
Copy link
Owner

EnriqCG commented Jan 4, 2021

Decoding a payload into a JSON object requires the following extra code on every single controller.

@Consume('queueName')
function handleCreatedEvent(content: string) {
  const eventData = JSON.parse(content)
  // do something with the eventData object
}

Eventually, I'd like to implement a decorator that decodes the JSON payload automatically and potentially runs validation checks (with Data Transfer Objects) against it. NestJS already provides something similar for their HTTP controllers:

NestJS Implementation with HTTP

@Get('/')
function findAll(@Body() payload: payloadDTO) {
  // do something with `payload` already decoded into a JS object
}

What I want to achieve

@Consume('queueName')
function handleCreatedEvent(@EventPayload() payload: payloadDTO) {
  // do something with the payload object
}
@EnriqCG EnriqCG added the enhancement New feature or request label Jan 4, 2021
@EnriqCG EnriqCG added this to the Version 1.0 milestone Jan 4, 2021
@EnriqCG
Copy link
Owner Author

EnriqCG commented Nov 9, 2021

Moving this to milestone Version 1.1.

@EnriqCG EnriqCG modified the milestones: Version 1.0, Version 1.1 Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant