foal
foal copied to clipboard
Make A Controller's Request Typed
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;
}
}