I would like to make my route Query parameter required.
If it is missing I expect it to throw 404 HTTP error.
@Controller('')
export class AppController {
constructor() {}
@Get('/businessdata/messages')
public async getAllMessages(
@Query('startDate', ValidateDate) startDate: string,
@Query('endDate', ValidateDate) endDate: string,
): Promise<string> {
...
}
}
I'm using NestJs pipes to determine if a parameter is valid, but not if it exists And I'm not sure that Pipes are made for that.
So how can I check in NestJS if my param exists if not throw an error?