import * as _navios_core0 from "@navios/core"; import { AbstractDynamicHandler, AbstractExecutionContext, AbstractHandlerAdapterService, AbstractHttpAdapterInterface, AbstractHttpHandlerAdapterInterface, AbstractStaticHandler, AnyInjectableType, ArgumentGetter, ClassType, Container, ControllerMetadata, FormatArgumentsFn, HandlerContext, HandlerMetadata, HttpAdapterEnvironment, InjectionToken, InstanceResolution, LogLevel, LoggerService, ModuleMetadata, ScopedContainer } from "@navios/core"; import * as fastify0 from "fastify"; import { FastifyInstance, FastifyListenOptions, FastifyReply, FastifyRequest, FastifySchemaCompiler, FastifyServerOptions } from "fastify"; import { BaseEndpointOptions, EndpointOptions } from "@navios/builder"; import { FastifyCorsOptions } from "@fastify/cors"; import { FastifyMultipartOptions } from "@fastify/multipart"; import { $ZodType } from "zod/v4/core"; import * as http0 from "http"; import * as fastify_types_type_provider_js0 from "fastify/types/type-provider.js"; //#region src/adapters/handler-adapter.interface.d.mts /** * Static handler result for Fastify - handler can be called without a scoped container. * Used when the controller and all its dependencies are singletons. */ type FastifyStaticHandler = { isStatic: true; handler: (request: FastifyRequest, reply: FastifyReply) => Promise; }; /** * Dynamic handler result for Fastify - handler requires a scoped container for resolution. * Used when the controller or its dependencies need per-request resolution. */ type FastifyDynamicHandler = { isStatic: false; handler: (scoped: ScopedContainer, request: FastifyRequest, reply: FastifyReply) => Promise; }; /** * Handler result returned by provideHandler for Fastify adapters. * Can be either static (pre-resolved) or dynamic (needs scoped container). */ type FastifyHandlerResult = FastifyStaticHandler | FastifyDynamicHandler; /** * Interface for Fastify handler adapter services. * * This interface defines the contract for adapter services that handle * different types of HTTP requests in Fastify. Adapters are responsible for: * - Parsing and validating request data * - Creating handler functions * - Formatting responses * - Providing schema information for Fastify's validation system * * Different adapter implementations handle different endpoint types: * - `FastifyEndpointAdapterService`: Standard REST endpoints * - `FastifyStreamAdapterService`: Streaming endpoints * - `FastifyMultipartAdapterService`: File upload and multipart endpoints * * @extends {AbstractHttpHandlerAdapterInterface} */ interface FastifyHandlerAdapterInterface extends AbstractHttpHandlerAdapterInterface { /** * Provides Fastify schema information for the handler (optional). * * Creates a Fastify route schema object that enables built-in validation * and serialization. The schema typically includes `body`, `querystring`, * and `response` properties. * * @param handlerMetadata - The handler metadata containing configuration and schemas. * @returns Fastify route schema object. */ provideSchema?: (handlerMetadata: HandlerMetadata) => Record; /** * Checks if the handler has any validation schemas defined (optional). * * @param handlerMetadata - The handler metadata containing configuration. * @returns `true` if the handler has any schemas (request, query, response). */ hasSchema?: (handlerMetadata: HandlerMetadata) => boolean; /** * Prepares argument getters for parsing request data (optional). * * Creates functions that extract and validate data from the request, * populating a target object with validated arguments. * * @param handlerMetadata - The handler metadata with schemas and configuration. * @returns An array of getter functions that populate request arguments. */ prepareArguments?: (handlerMetadata: HandlerMetadata) => ((target: Record, request: FastifyRequest) => Promise | void)[]; /** * Creates a request handler function for the endpoint. * * This is the core method that generates the actual handler function * that will be called when a request matches the endpoint. The handler * receives the request and reply objects for full control over the * request/response lifecycle. * * @param controller - The controller class containing the handler method. * @param handlerMetadata - The handler metadata with configuration and schemas. * @returns A handler result that is either static or dynamic. */ provideHandler: (controller: ClassType, handlerMetadata: HandlerMetadata) => Promise; } //#endregion //#region src/adapters/abstract-fastify-handler-adapter.service.d.mts /** * Abstract base class for Fastify handler adapters. * * Provides shared argument parsing logic for Fastify: * - Query parameters via request.query * - Request body via request.body * - URL parameters via request.params * * Concrete adapters (Endpoint, Stream) implement response handling * via createStaticHandler and createDynamicHandler. * * @typeParam TConfig - Endpoint configuration type */ declare abstract class AbstractFastifyHandlerAdapterService extends AbstractHandlerAdapterService { /** * Creates argument getters for Fastify request parsing. * * Handles: * - Query params: Extracts from request.query (pre-validated by Fastify) * - Request body: Extracts from request.body (pre-validated by Fastify) * - URL params: Extracts route parameters from request.params */ protected createArgumentGetters(handlerMetadata: HandlerMetadata): ArgumentGetter[]; /** * Checks if the handler has any validation schemas defined. * * @param handlerMetadata - The handler metadata containing configuration. * @returns `true` if the handler has request, query, or error schemas. */ hasSchema(handlerMetadata: HandlerMetadata): boolean; /** * Provides Fastify schema information for the handler. * * Creates a Fastify route schema object that includes request body and * query string schemas. This enables Fastify's built-in validation. * * @param handlerMetadata - The handler metadata containing configuration and schemas. * @returns A Fastify route schema object. */ provideSchema(handlerMetadata: HandlerMetadata): Record; } //#endregion //#region src/adapters/stream-adapter.service.d.mts /** * Injection token for the Fastify stream adapter service. * * This token is used to inject the `FastifyStreamAdapterService` instance * into the dependency injection container. */ declare const FastifyStreamAdapterToken: InjectionToken; /** * Adapter service for handling streaming requests and responses in Fastify. * * This service extends `AbstractFastifyHandlerAdapterService` and provides * handling for stream-based endpoints. Handlers receive the Fastify reply * object for direct control over the response stream. * * @extends {AbstractFastifyHandlerAdapterService} * * @example * ```ts * // Used automatically when defining endpoints with @Stream() * @Controller() * class StreamController { * @Stream(streamEvents) * async streamData(data: StreamDto, reply: FastifyReply) { * reply.type('text/event-stream') * // Use reply object to stream data * reply.send(stream) * } * } * ``` */ declare class FastifyStreamAdapterService extends AbstractFastifyHandlerAdapterService { /** * Creates a static handler for singleton controllers. * * Passes the Fastify reply object as the second argument to the controller method * for direct stream control. * * @param boundMethod - Pre-bound controller method * @param formatArguments - Function to format request arguments * @param context - Handler context with metadata * @returns Static handler result */ protected createStaticHandler(boundMethod: (...args: any[]) => Promise, formatArguments: FormatArgumentsFn, context: HandlerContext): AbstractStaticHandler; /** * Creates a dynamic handler for request-scoped controllers. * * Passes the Fastify reply object as the second argument to the controller method * for direct stream control. * * @param resolution - Instance resolution with resolve function * @param formatArguments - Function to format request arguments * @param context - Handler context with metadata * @returns Dynamic handler result */ protected createDynamicHandler(resolution: InstanceResolution, formatArguments: FormatArgumentsFn, context: HandlerContext): AbstractDynamicHandler; } //#endregion //#region src/adapters/endpoint-adapter.service.d.mts /** * Injection token for the Fastify endpoint adapter service. * * This token is used to inject the `FastifyEndpointAdapterService` instance * into the dependency injection container. */ declare const FastifyEndpointAdapterToken: InjectionToken; /** * Adapter service for handling standard REST endpoint requests in Fastify. * * This service extends `FastifyStreamAdapterService` and provides specialized * handling for REST endpoints with request/response schema validation. * It automatically parses request bodies, query parameters, and URL parameters, * validates them against Zod schemas, and formats responses according to * response schemas using Fastify's schema system. * * @extends {FastifyStreamAdapterService} * * @example * ```ts * // Used automatically when defining endpoints with @Endpoint() * @Controller() * class UserController { * @Endpoint({ * method: 'POST', * url: '/users', * requestSchema: createUserSchema, * responseSchema: userSchema, * }) * async createUser(data: CreateUserDto) { * // data is validated against createUserSchema * return { id: 1, ...data } // Response validated against userSchema * } * } * ``` */ declare class FastifyEndpointAdapterService extends FastifyStreamAdapterService { /** * Checks if the handler has any validation schemas defined. * * @param handlerMetadata - The handler metadata containing configuration. * @returns `true` if the handler has request, query, or response schemas. */ hasSchema(handlerMetadata: HandlerMetadata): boolean; /** * Provides Fastify schema information for the handler. * * Creates a Fastify route schema object that includes request body, query string, * and response schemas. This enables Fastify's built-in validation and serialization. * * @param handlerMetadata - The handler metadata containing configuration and schemas. * @returns A Fastify route schema object. */ provideSchema(handlerMetadata: HandlerMetadata): Record; /** * Creates a static handler for singleton controllers. * * Invokes the controller method and sends the response with proper status and headers. * * @param boundMethod - Pre-bound controller method * @param formatArguments - Function to format request arguments * @param context - Handler context with metadata * @returns Static handler result */ protected createStaticHandler(boundMethod: (...args: any[]) => Promise, formatArguments: FormatArgumentsFn, context: HandlerContext): AbstractStaticHandler; /** * Creates a dynamic handler for request-scoped controllers. * * Resolves the controller per-request and sends the response with proper status and headers. * * @param resolution - Instance resolution with resolve function * @param formatArguments - Function to format request arguments * @param context - Handler context with metadata * @returns Dynamic handler result */ protected createDynamicHandler(resolution: InstanceResolution, formatArguments: FormatArgumentsFn, context: HandlerContext): AbstractDynamicHandler; } //#endregion //#region src/adapters/multipart-adapter.service.d.mts /** * Injection token for the Fastify multipart adapter service. * * This token is used to inject the `FastifyMultipartAdapterService` instance * into the dependency injection container. */ declare const FastifyMultipartAdapterToken: InjectionToken; /** * Adapter service for handling multipart/form-data requests in Fastify. * * This service extends `FastifyEndpointAdapterService` and provides specialized * handling for file uploads and multipart form data. It automatically parses * multipart streams, handles file uploads, converts files to File objects, * and validates the data against Zod schemas. * * @extends {FastifyEndpointAdapterService} * * @example * ```ts * // Used automatically when defining endpoints with @Multipart() * @Controller() * class UploadController { * @Multipart({ * method: 'POST', * url: '/upload', * requestSchema: uploadSchema, * }) * async uploadFile(data: UploadDto) { * // data contains parsed form fields and File objects * return { success: true } * } * } * ``` */ declare class FastifyMultipartAdapterService extends FastifyEndpointAdapterService { /** * Creates argument getters for parsing multipart form data. * * This method creates an array of functions that extract and validate * data from multipart requests, including: * - Query parameters * - URL parameters * - Form fields and file uploads from multipart streams * * Files are converted to File objects, and form fields are parsed and * validated against the request schema. Supports arrays and nested objects. * * @param handlerMetadata - The handler metadata with schemas and configuration. * @returns An array of getter functions that populate request arguments. */ protected createArgumentGetters(handlerMetadata: HandlerMetadata): ArgumentGetter[]; /** * Provides Fastify schema information for multipart handlers. * * Creates a Fastify route schema object that includes query string and * response schemas. Note that multipart body schemas are handled separately * during request parsing. * * @param handlerMetadata - The handler metadata containing configuration and schemas. * @returns A Fastify route schema object. */ provideSchema(handlerMetadata: HandlerMetadata): Record; /** * Populates the request object with multipart data. * * Handles file uploads, form fields, arrays, and nested objects based on * the schema structure. * * @param structure - Schema structure analysis results. * @param part - Multipart part (file or value). * @param req - Request object to populate. * @private */ private populateRequest; /** * Analyzes the Zod schema shape to determine field types. * * Determines which fields are arrays, optional, or objects to properly * handle multipart parsing. * * @param shape - The Zod schema shape definition. * @returns An object mapping field names to their type information. * @private */ private analyzeSchema; } //#endregion //#region src/interfaces/environment.interface.d.mts /** * Environment interface for the Fastify HTTP adapter. * * Provides type-safe access to Fastify-specific types when using * `NaviosApplication`. * * @example * ```typescript * import { defineFastifyEnvironment, FastifyEnvironment } from '@navios/adapter-fastify' * import { NaviosFactory } from '@navios/core' * * const app = await NaviosFactory.create(AppModule, { * adapter: defineFastifyEnvironment(), * }) * * // All methods are now type-safe for Fastify * app.configure({ trustProxy: true }) * app.enableCors({ origin: true }) // FastifyCorsOptions * const server = app.getServer() // FastifyInstance * await app.listen({ port: 3000 }) // FastifyListenOptions * ``` */ interface FastifyEnvironment extends HttpAdapterEnvironment { /** FastifyInstance from the fastify package */ server: FastifyInstance; /** FastifyCorsOptions from @fastify/cors */ corsOptions: FastifyCorsOptions; /** FastifyMultipartOptions from @fastify/multipart */ multipartOptions: FastifyMultipartOptions; /** FastifyListenOptions for server listen configuration */ listenOptions: FastifyListenOptions; /** FastifyApplicationOptions for server setup */ options: FastifyApplicationOptions; /** FastifyApplicationServiceInterface for the Fastify application service */ adapter: FastifyApplicationServiceInterface; } //#endregion //#region src/interfaces/application.interface.d.mts /** * Configuration options for the Fastify HTTP server. * * Extends Fastify's native `FastifyServerOptions` with Navios-specific * logger configuration. These options are passed to `fastify()` when * the server is created. * * @example * ```ts * app.configure({ * logger: true, * trustProxy: true, * disableRequestLogging: false, * requestIdHeader: 'x-request-id', * }) * await app.init() * ``` * * @see {@link https://www.fastify.io/docs/latest/Reference/Server/} Fastify server options documentation */ interface FastifyApplicationOptions extends Omit { /** * Specifies the logger to use. Pass `false` to turn off logging. * * - `LoggerService`: Use a custom logger service instance * - `LogLevel[]`: Array of log levels to enable (e.g., `['error', 'warn']`) * - `false`: Disable logging completely * - `true`: Use default Pino logger */ logger?: LoggerService | LogLevel[] | false; } /** * Interface for the Fastify application service. * * This interface defines the contract for the Fastify HTTP adapter service, * extending the base `AbstractHttpAdapterInterface` with Fastify-specific * methods and types. It includes support for CORS, multipart form data, * and full access to Fastify's plugin ecosystem. * * @extends {AbstractHttpAdapterInterface} * * @example * ```ts * const app = await NaviosFactory.create(AppModule, { * adapter: defineFastifyEnvironment(), * }) * * app.configure({ logger: true }) * app.enableCors({ origin: true }) * app.enableMultipart({ limits: { fileSize: 10 * 1024 * 1024 } }) * await app.init() * await app.listen({ port: 3000 }) * ``` */ interface FastifyApplicationServiceInterface extends AbstractHttpAdapterInterface { initServer(): Promise; } //#endregion //#region src/interfaces/fastify-execution-context.interface.d.mts /** * Execution context for Fastify adapter requests. * * This class provides access to metadata about the current request's * module, controller, handler, request, and reply objects. It's used by guards, * interceptors, and other request-scoped services to access context * information and interact with Fastify's request/reply objects. * * @implements {AbstractExecutionContext} * * @example * ```ts * @Injectable() * class AuthGuard implements CanActivate { * canActivate(context: FastifyExecutionContext): boolean { * const request = context.getRequest() * const reply = context.getReply() * const handler = context.getHandler() * // Check authentication based on handler metadata * return true * } * } * ``` */ declare class FastifyExecutionContext implements AbstractExecutionContext { private readonly module; private readonly controller; private readonly handler; private readonly request; private readonly reply; constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: HandlerMetadata, request: FastifyRequest, reply: FastifyReply); /** * Gets the module metadata for the current request. * * @returns The module metadata containing module configuration and dependencies. */ getModule(): ModuleMetadata; /** * Gets the controller metadata for the current request. * * @returns The controller metadata containing controller configuration. */ getController(): ControllerMetadata; /** * Gets the handler metadata for the current request. * * @returns The handler metadata containing endpoint configuration, schemas, and method information. */ getHandler(): HandlerMetadata; /** * Gets the current Fastify request object. * * @returns The Fastify request object for the current request. * @throws {Error} If the request is not set. */ getRequest(): FastifyRequest; /** * Gets the current Fastify reply object. * * The reply object provides methods for sending responses, setting headers, * and controlling the response stream. * * @returns The Fastify reply object for the current request. * @throws {Error} If the reply is not set. */ getReply(): FastifyReply; } //#endregion //#region src/types/fastify.d.mts declare module 'fastify' { interface FastifyRequest { scopedContainer?: ScopedContainer; } } //# sourceMappingURL=fastify.d.mts.map //#endregion //#region src/services/controller-adapter.service.d.mts /** * 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 {} * ``` */ 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; } //#endregion //#region src/services/application.service.d.mts /** * Fastify HTTP adapter service implementation for Navios. * * This service provides the core HTTP server functionality for Navios applications * running on the Fastify runtime. It handles server initialization, route registration, * request handling, CORS configuration, multipart support, and server lifecycle management. * * @example * ```ts * const app = await NaviosFactory.create(AppModule, { * adapter: defineFastifyEnvironment(), * }) * * app.configure({ * logger: true, * trustProxy: true, * }) * * app.enableCors({ origin: true }) * app.enableMultipart({ limits: { fileSize: 10 * 1024 * 1024 } }) * * await app.init() * await app.listen({ port: 3000, host: '0.0.0.0' }) * ``` * * @implements {FastifyApplicationServiceInterface} */ declare class FastifyApplicationService implements FastifyApplicationServiceInterface { private logger; protected container: Container; private errorProducer; private validatorCompiler; private server; private controllerAdapter; private globalPrefix; private corsOptions; private multipartOptions; private configureOptions; /** * Sets up the Fastify HTTP adapter with the provided options. * * This method is called during application initialization. * It creates the Fastify instance, configures logging, and prepares the server * for route registration. * * @param options - Fastify server configuration options including logger settings, * trust proxy configuration, and other Fastify-specific options. * * @example * ```ts * app.configure({ * logger: true, * trustProxy: true, * disableRequestLogging: false, * }) * await app.init() * ``` */ setupAdapter(options: FastifyApplicationOptions): Promise; /** * Initializes the Fastify server instance and configures plugins. * * This method is called automatically during server setup. It configures * error handlers, not found handlers, schema validators, and registers * the server instance in the dependency injection container. */ initServer(): Promise; /** * Waits for the Fastify server to be ready. * * This method ensures all plugins are registered and the server is ready * to accept connections before starting to listen. */ ready(): Promise; /** * Sets a global prefix for all routes. * * This prefix will be prepended to all registered route paths. Useful for * API versioning or organizing routes under a common path. * * @param prefix - The prefix to prepend to all routes (e.g., '/api/v1'). * Should start with a forward slash. * * @example * ```ts * app.setGlobalPrefix('/api/v1') * // All routes will be prefixed with /api/v1 * ``` */ setGlobalPrefix(prefix: string): void; /** * Gets the current global prefix for all routes. * * @returns The global prefix string, or empty string if no prefix is set. * * @example * ```ts * app.setGlobalPrefix('/api/v1') * console.log(app.getGlobalPrefix()) // '/api/v1' * ``` */ getGlobalPrefix(): string; /** * Gets the underlying Fastify server instance. * * This allows direct access to the Fastify instance for advanced use cases, * such as registering custom plugins, hooks, or decorators. * * @returns The Fastify server instance. * @throws {Error} If the server has not been initialized yet. * * @example * ```ts * const fastify = app.getServer() * await fastify.register(require('@fastify/static'), { * root: path.join(__dirname, 'public'), * }) * ``` */ getServer(): FastifyInstance; onModulesInit(modules: Map): Promise; /** * Configures Fastify instance with error handlers, validators, and serializers. * * Sets up: * - Global error handler for HttpException and other errors * - Not found handler for unmatched routes * - Zod-based validator and serializer compilers * * @private */ configureFastifyInstance(): void; /** * Configures and registers Fastify plugins (CORS, multipart, etc.). * * This method registers plugins that were configured via `enableCors()` * and `enableMultipart()` methods. * * @private */ configurePlugins(): Promise; /** * Configures multipart form data support. * * @param options - Multipart configuration options or `true` for defaults. * @private */ configureMultipart(options: FastifyMultipartOptions | true): Promise; /** * Registers the Fastify instance in the dependency injection container. * * Makes the server instance available for injection via `FastifyServerToken`. * * @private */ registerFastifyInstance(): void; /** * Enables CORS (Cross-Origin Resource Sharing) support. * * Configures CORS headers for all routes. The options are applied when * the server is initialized. * * @param options - CORS configuration options from `@fastify/cors`. * * @example * ```ts * app.enableCors({ * origin: true, // Allow all origins * methods: ['GET', 'POST', 'PUT', 'DELETE'], * credentials: true, * }) * ``` * * @see {@link https://github.com/fastify/fastify-cors} Fastify CORS plugin documentation */ enableCors(options: FastifyCorsOptions): void; /** * Enables multipart form data support for file uploads. * * Configures multipart handling for all routes. The options are applied when * the server is initialized. * * @param options - Multipart configuration options from `@fastify/multipart`. * * @example * ```ts * app.enableMultipart({ * limits: { * fileSize: 10 * 1024 * 1024, // 10MB * files: 5, // Max 5 files * }, * }) * ``` * * @see {@link https://github.com/fastify/fastify-multipart} Fastify Multipart plugin documentation */ enableMultipart(options: FastifyMultipartOptions): void; /** * Starts the Fastify HTTP server and begins listening for incoming requests. * * This method starts the server with the configured routes and options. * The server will handle all registered routes and return 404 for unmatched requests. * * @param options - Server listen options including port and host. * @returns A promise that resolves to the server address string. * * @example * ```ts * const address = await app.listen({ * port: 3000, * host: '0.0.0.0', * }) * console.log(`Server listening on ${address}`) * ``` */ listen(options: FastifyListenOptions): Promise; /** * Configures the adapter with additional options before initialization. * * Options set via configure() are merged with options passed to * setupAdapter(), with configure() options taking precedence. * Must be called before init(). * * @param options - Partial Fastify server configuration options * * @example * ```ts * app.configure({ trustProxy: true, logger: true }) * await app.init() * ``` */ configure(options: Partial): void; /** * Gracefully shuts down the Fastify server. * * This method closes all connections and cleans up resources. Should be called * during application shutdown to ensure proper cleanup. * * @example * ```ts * process.on('SIGTERM', async () => { * await app.dispose() * process.exit(0) * }) * ``` */ dispose(): Promise; } //#endregion //#region src/services/fastify-validator-compiler.service.d.mts declare class FastifyValidatorCompilerService { errorCompiler: FastifySchemaCompiler<$ZodType>; } //#endregion //#region src/services/pino-wrapper.d.mts declare class PinoWrapper { protected container: Container; protected logger: _navios_core0.LoggerInstance; fatal(message: any, ...optionalParams: any[]): void; error(message: any, ...optionalParams: any[]): void; warn(message: any, ...optionalParams: any[]): void; info(): void; debug(message: any, ...optionalParams: any[]): void; trace(message: any, ...optionalParams: any[]): void; silent(): void; child(options: any): any; get level(): any; } //#endregion //#region src/tokens/server.token.d.mts /** * Injection token for the Fastify server instance. * * This token provides access to the underlying Fastify server instance, * allowing direct interaction with Fastify's API for advanced use cases * such as registering custom plugins, hooks, decorators, or accessing * server-level functionality. * * @example * ```ts * @Injectable() * class PluginService { * private server = inject(FastifyServerToken) * * async registerStaticFiles() { * await this.server.register(require('@fastify/static'), { * root: path.join(__dirname, 'public'), * prefix: '/public/', * }) * } * } * ``` */ declare const FastifyServerToken: InjectionToken, fastify0.FastifyBaseLogger, fastify0.FastifyTypeProviderDefault>, undefined, false>; //#endregion //#region src/tokens/request.token.d.mts /** * Injection token for the current Fastify request object. * * This token provides access to the current HTTP request within request-scoped * services. The request is automatically injected into the request-scoped container * for each incoming request. * * @example * ```ts * @Injectable() * class RequestService { * private request = inject(FastifyRequestToken) * * getUrl() { * return this.request.url * } * * getMethod() { * return this.request.method * } * * getHeaders() { * return this.request.headers * } * } * ``` */ declare const FastifyRequestToken: InjectionToken>, undefined, false>; //#endregion //#region src/tokens/reply.token.d.mts /** * Injection token for the current Fastify reply object. * * This token provides access to the current HTTP response object within request-scoped * services. The reply is automatically injected into the request-scoped container * for each incoming request, allowing direct control over the response. * * @example * ```ts * @Injectable() * class ResponseService { * private reply = inject(FastifyReplyToken) * * setHeader(key: string, value: string) { * this.reply.header(key, value) * } * * send(data: any) { * this.reply.send(data) * } * } * ``` */ declare const FastifyReplyToken: InjectionToken, unknown, fastify0.FastifySchema, fastify0.FastifyTypeProviderDefault, unknown>, undefined, false>; //#endregion //#region src/tokens/fastify-application.token.d.mts /** * Injection token for the Fastify application service. * * This token is used to inject the `FastifyApplicationService` instance * into the dependency injection container. It provides access to the * HTTP adapter service for advanced use cases. * * @example * ```ts * @Injectable() * class MyService { * private appService = inject(FastifyApplicationServiceToken) * * getServer() { * return this.appService.getServer() * } * } * ``` */ declare const FastifyApplicationServiceToken: InjectionToken; //#endregion //#region src/define-environment.d.mts /** * Creates a Fastify adapter environment configuration for Navios. * * This function sets up the necessary dependency injection tokens and services * required to run Navios applications on the Fastify runtime. It configures: * - HTTP adapter service for handling HTTP requests * - Endpoint adapter for standard REST endpoints * - Stream adapter for streaming responses * - Multipart adapter for file uploads and form data * - Request and Reply tokens for accessing Fastify request/reply objects * * @returns An object containing the token mappings for the Fastify adapter. * This object should be passed to `NaviosFactory.create()` as the `adapter` option. * * @example * ```ts * import { defineFastifyEnvironment } from '@navios/adapter-fastify' * import { NaviosFactory } from '@navios/core' * * const app = await NaviosFactory.create(AppModule, { * adapter: defineFastifyEnvironment(), * }) * ``` * * @example * ```ts * // With CORS and multipart support * const app = await NaviosFactory.create(AppModule, { * adapter: defineFastifyEnvironment(), * }) * * app.enableCors({ * origin: true, * methods: ['GET', 'POST', 'PUT', 'DELETE'], * }) * * app.enableMultipart({ * limits: { fileSize: 10 * 1024 * 1024 }, // 10MB * }) * ``` * * @see {@link FastifyApplicationService} The HTTP adapter service implementation * @see {@link FastifyEndpointAdapterService} The endpoint adapter implementation * @see {@link FastifyStreamAdapterService} The stream adapter implementation * @see {@link FastifyMultipartAdapterService} The multipart adapter implementation */ declare function defineFastifyEnvironment(): { tokens: Map, AnyInjectableType>; }; //#endregion export { AbstractFastifyHandlerAdapterService, FastifyApplicationOptions, FastifyApplicationService, FastifyApplicationServiceInterface, FastifyApplicationServiceToken, FastifyControllerAdapterService, FastifyDynamicHandler, FastifyEndpointAdapterService, FastifyEndpointAdapterToken, FastifyEnvironment, FastifyExecutionContext, FastifyHandlerAdapterInterface, FastifyHandlerResult, FastifyMultipartAdapterService, FastifyMultipartAdapterToken, FastifyReplyToken, FastifyRequestToken, FastifyServerToken, FastifyStaticHandler, FastifyStreamAdapterService, FastifyStreamAdapterToken, FastifyValidatorCompilerService, PinoWrapper, defineFastifyEnvironment }; //# sourceMappingURL=index.d.cts.map