Managing the route’s scope
In Fastify, an endpoint has two central aspects that you will set when defining a new route:
- The route configuration
- The server instance, where the route has been registered
This metadata controls how the route behaves when the client calls it. Earlier in this chapter, we saw the first point, but now we must deepen the second aspect: the server instance context. The route’s scope is built on top of the server’s instance context where the entry point has been registered. Every route has its own route scope that is built during the startup phase, and it is like a settings container that tracks the handler’s configuration. Let’s see how it works.
The route server instance
When we talk about the route’s scope, we must consider the server instance where the route has been added. This information is important because it will define the following:
- The handler execution context
- The request...