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

Make A Controller's Request Typed #1269

Open
ConorCorp opened this issue Jul 4, 2024 · 2 comments · May be fixed by #1270
Open

Make A Controller's Request Typed #1269

ConorCorp opened this issue Jul 4, 2024 · 2 comments · May be fixed by #1270

Comments

@ConorCorp
Copy link

Hi there, would love to have all my request params/body/etc. I already define them in ValidatePathParam and ValidateBody, so I know that they will be the correct types.

Ideally, this would happen automatically and ValidatePathParam would just pass the correct types into ctx's request object.

export class ApproverController {
  @Get()
  @ValidatePathParam('versionId', { type: 'string', format: 'uuid' })
  async getDocumentVersionApprovers(ctx: Context) {
      const {
      request: {
        params: { versionId }, // <----- This is an "any", and it should be a string
      },
      user,
    } = ctx;
}
}
@ConorCorp ConorCorp linked a pull request Jul 4, 2024 that will close this issue
3 tasks
@ConorCorp
Copy link
Author

ConorCorp commented Jul 4, 2024

Here's a patch package in the meantime with an identical solution to the linked PR.

@foal+core+4.4.0.patch

@ConorCorp
Copy link
Author

I added another patch package here which also adds typing to the query params.

I didn't put it in the PR as I haven't heard back anything yet. Can add it in though if there's movement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant