What is the use of @All decorator in NestJS and does it handle all the requests that are not handled in other routes?
Asked
Active
Viewed 38 times
1 Answers
3
@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

Jay McDoniel
- 57,339
- 7
- 135
- 147