What is the use of @All decorator in NestJS and does it handle all the requests that are not handled in other routes?
@All()
is used for all supported HTTP Verbs. So @All('/hello')
would essentially be @Post('/hello')
, @Put('/hello')
, @Get('/hello')
, @Delete('/hello')
, and @Patch('/hello')
.
If you want a catch-all handler, you can use @All('*')
, just make sure this is the last registered route handler as it will match everything and if it is registered too early then it will handle even your named routes