request.server
A reference to the Fastify instance that registered the route.
Syntax
request.server Returns
FastifyInstance — The encapsulated instance handling the request.
Examples
import Fastify from 'fastify';
const app = Fastify();
app.decorate('db', { ping: async () => true });
app.get('/health', async (req) => {
return { db: await req.server.db.ping() };
});
Notes
request.server points to the encapsulated instance, so it resolves
decorators added within the same plugin scope. Useful for accessing
shared services without closing over the outer variable.