import type { ClassType, ModuleMetadata } from '@navios/core'; import type { BunRequest } from 'bun'; import { type BunCorsOptions } from '../utils/cors.util.mjs'; /** * Type definition for Bun route mappings. * * Maps route paths to HTTP method handlers. Each route path can have * multiple HTTP methods (GET, POST, PUT, DELETE, etc.) associated with it. */ export type BunRoutes = Record Response | Promise; }>; /** * Service responsible for adapting Navios controllers to Bun route handlers. * * This service processes controller metadata, sets up route handlers, * integrates with guards, and handles request/response lifecycle. It * bridges the gap between Navios's controller decorators and Bun's * native routing system. * * @example * ```ts * // This service is used automatically by the Bun adapter * // Controllers are automatically registered when modules are initialized * @Module({ * controllers: [UserController], * }) * class AppModule {} * ``` */ export declare class BunControllerAdapterService { 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 Bun's routing system. * * @param controller - The controller class to set up. * @param routes - The routes object to populate with handlers. * @param moduleMetadata - Metadata about the module containing the controller. * @param globalPrefix - The global prefix to prepend to all routes. * @param corsOptions - Optional CORS configuration to apply to responses. * * @throws {Error} If an endpoint is malformed (missing URL or adapter token). */ setupController(controller: ClassType, routes: BunRoutes, moduleMetadata: ModuleMetadata, globalPrefix: string, corsOptions?: BunCorsOptions | null): Promise; /** * Wraps a route handler with request context, guards, error handling, and CORS. * * This method creates a complete request handler using one of three paths: * 1. Static handler + no guards: Direct handler call (fastest) * 2. Static handler + static guards: Call pre-resolved guards, then handler * 3. Dynamic: Full flow with scoped 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. * @param corsOptions - Optional CORS configuration to apply to responses. * @returns A wrapped handler function that can be registered with Bun. * @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