foal icon indicating copy to clipboard operation
foal copied to clipboard

Make A Controller's Request Typed

Open ConorCorp opened this issue 7 months ago • 2 comments

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 avatar Jul 04 '24 20:07 ConorCorp