import type { ClassType, ModuleMetadata } from '@navios/core'; import type { FastifyInstance } from 'fastify'; import '../types/fastify.mjs'; /** * Service responsible for adapting Navios controllers to Fastify route handlers. * * This service processes controller metadata, sets up route handlers with * Fastify's routing system, integrates with guards, and handles request/response * lifecycle. It bridges the gap between Navios's controller decorators and * Fastify's native routing system, including schema-based route registration. * * @example * ```ts * // This service is used automatically by the Fastify adapter * // Controllers are automatically registered when modules are initialized * @Module({ * controllers: [UserController], * }) * class AppModule {} * ``` */ export declare class FastifyControllerAdapterService { private guardRunner; private container; private instanceResolver; private errorProducer; private logger; /** * Sets up route handlers for a controller. * * This method processes all endpoints defined in a controller, creates * appropriate route handlers using the configured adapter services, * and registers them with Fastify's routing system. Routes with schemas * are registered with Fastify's type provider for enhanced type safety. * * @param controller - The controller class to set up. * @param instance - The Fastify instance to register routes on. * @param moduleMetadata - Metadata about the module containing the controller. * * @throws {Error} If an endpoint is malformed (missing URL or adapter token). */ setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): Promise; /** * Creates a scoped container and attaches it to the request. * Used when handler or guards need request-scoped resolution. * @private */ private createRequestContainer; /** * Creates execution context and optionally adds it to container. * @private */ private createExecutionContext; /** * Creates a static handler wrapper (no scoped container needed). * @private */ private makeStaticHandler; /** * Creates a dynamic handler wrapper (uses scoped container from request). * @private */ private makeDynamicHandler; /** * Creates a preHandler that runs static guards. * @private */ private makeStaticGuardsPreHandler; /** * Creates a preHandler that runs dynamic guards (needs scoped container). * If endContainerAfter=true, container is ended in finally block. * @private */ private makeDynamicGuardsPreHandler; /** * Wraps a route handler with request context, guards, and error handling. * * This method creates route handlers using one of five paths: * 1. Static handler + no guards: Direct handler call (fastest) * 2. Static handler + static guards: preHandler runs guards, handler is direct * 3. Static guards + dynamic handler: preHandler creates container and runs guards * 4. Dynamic guards + static handler: preHandler creates container, runs guards, ends container * 5. Dynamic guards + dynamic handler: preHandler creates container, runs guards, onResponse ends container * * @param handlerResult - The handler result from the adapter service. * @param guardResolution - Pre-resolved guards or resolver function. * @param moduleMetadata - Metadata about the module. * @param controllerMetadata - Metadata about the controller. * @param endpoint - Metadata about the endpoint handler. * @returns Route handlers with optional preHandler. * @private */ private wrapHandler; /** * Handles errors and converts them to appropriate HTTP responses. * Uses ErrorResponseProducerService to produce RFC 7807 compliant responses. * @private */ private handleError; } //# sourceMappingURL=controller-adapter.service.d.mts.map