Chapter 10. Routing and request handling in Nest.js
Routing and request handling in Nest.js is handled by the controllers layer. Nest.js routes requests to handler methods, which are defined inside controller classes. Adding a routing decorator such as @Get()
to a method in a controller tells Nest.js to create an endpoint for this route path and route every corresponding request to this handler.
In this chapter, we’ll go over the various aspects of routing and request handling in Nest.js using the EntryController from our blog application as a basis for some examples. We’ll be looking at different approaches that you can use to write request handlers, so not all examples shown will match code from our blog application.