import { AbstractDynamicHandler, AbstractExecutionContext, AbstractHandlerAdapterService, AbstractHttpAdapterInterface, AbstractHttpCorsOptions, AbstractHttpHandlerAdapterInterface, AbstractStaticHandler, AnyInjectableType, ArgumentGetter, ClassType, Container, ControllerMetadata, FormatArgumentsFn, HandlerContext, HandlerMetadata, HttpAdapterEnvironment, InjectionToken, InstanceResolution, LogLevel, LoggerService, ModuleMetadata, ScopedContainer } from "@navios/core"; import { BunRequest, Serve, Server } from "bun"; import { BaseEndpointOptions, EndpointOptions } from "@navios/builder"; import { InjectionToken as InjectionToken$1 } from "@navios/di"; //#region src/adapters/handler-adapter.interface.d.mts /** * Static handler result for Bun - handler can be called without a scoped container. * Used when the controller and all its dependencies are singletons. */ type BunStaticHandler = { isStatic: true; handler: (request: BunRequest) => Promise; }; /** * Dynamic handler result for Bun - handler requires a scoped container for resolution. * Used when the controller or its dependencies need per-request resolution. */ type BunDynamicHandler = { isStatic: false; handler: (scoped: ScopedContainer, request: BunRequest) => Promise; }; /** * Handler result returned by provideHandler for Bun adapters. * Can be either static (pre-resolved) or dynamic (needs scoped container). */ type BunHandlerResult = BunStaticHandler | BunDynamicHandler; /** * Interface for Bun handler adapter services. * * This interface defines the contract for adapter services that handle * different types of HTTP requests in Bun. Adapters are responsible for: * - Parsing and validating request data * - Creating handler functions * - Formatting responses * - Providing schema information (if needed) * * Different adapter implementations handle different endpoint types: * - `BunEndpointAdapterService`: Standard REST endpoints * - `BunStreamAdapterService`: Streaming endpoints * - `BunMultipartAdapterService`: File upload and multipart endpoints * * @extends {AbstractHttpHandlerAdapterInterface} */ interface BunHandlerAdapterInterface extends AbstractHttpHandlerAdapterInterface { /** * Provides schema information for the handler (optional). * * For Bun adapter, this typically returns an empty object as Bun doesn't * require schema registration like some other frameworks. * * @param handlerMetadata - The handler metadata containing configuration. * @returns Schema information (usually empty for Bun). */ 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: BunRequest) => 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. * * @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-bun-handler-adapter.service.d.mts /** * Abstract base class for Bun handler adapters. * * Provides shared argument parsing logic for Bun: * - Query parameters via URL parsing * - Request body via request.json() * - URL parameters via request.params * * Concrete adapters (Endpoint, Stream) implement response handling * via createStaticHandler and createDynamicHandler. * * @typeParam TConfig - Endpoint configuration type */ declare abstract class AbstractBunHandlerAdapterService extends AbstractHandlerAdapterService { /** * Creates argument getters for Bun request parsing. * * Handles: * - Query params: Parses URL search params with schema validation * - Request body: Parses JSON body with schema validation * - URL params: Extracts route parameters from request.params */ protected createArgumentGetters(handlerMetadata: HandlerMetadata): ArgumentGetter[]; /** * Builds response headers from context. * Can be overridden by concrete adapters to add Content-Type, etc. */ protected buildHeaders(context: HandlerContext): Record; } //#endregion //#region src/adapters/stream-adapter.service.d.mts /** * Injection token for the Bun stream adapter service. * * This token is used to inject the `BunStreamAdapterService` instance * into the dependency injection container. */ declare const BunStreamAdapterToken: InjectionToken; /** * Adapter service for handling streaming requests and responses in Bun. * * This service extends `AbstractBunHandlerAdapterService` and provides * handling for stream-based endpoints. Handlers receive a streamWriter * stub and can return Response objects directly for streaming. * * @extends {AbstractBunHandlerAdapterService} * * @example * ```ts * // Used automatically when defining endpoints with @Stream() * @Controller() * class StreamController { * @Stream(streamEvents) * async streamData(data: StreamDto) { * // Returns a Response object for streaming * return new Response(stream, { * headers: { 'Content-Type': 'text/event-stream' }, * }) * } * } * ``` */ declare class BunStreamAdapterService extends AbstractBunHandlerAdapterService { /** * Creates a static handler for singleton controllers. * * Passes a streamWriter stub as the second argument to the controller method. * * @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 a streamWriter stub as the second argument to the controller method. * * @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; /** * Creates a stream writer stub for Bun. */ protected createStreamWriter(): { write: (_data: any) => void; end: () => void; }; /** * Creates a handler for stream results. * * If the result is a Response, adds custom headers. * Otherwise, wraps the result in a new Response. */ protected createStreamResultHandler(context: HandlerContext, headersTemplate: Record): (result: any) => Response; } //#endregion //#region src/adapters/endpoint-adapter.service.d.mts /** * Injection token for the Bun endpoint adapter service. * * This token is used to inject the `BunEndpointAdapterService` instance * into the dependency injection container. */ declare const BunEndpointAdapterToken: InjectionToken; /** * Adapter service for handling standard REST endpoint requests in Bun. * * This service extends `AbstractBunHandlerAdapterService` 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. * * @extends {AbstractBunHandlerAdapterService} * * @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 BunEndpointAdapterService extends AbstractBunHandlerAdapterService { /** * 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 schema information for the handler. * * For Bun adapter, this returns an empty object as Bun doesn't require * schema registration like some other frameworks. * * @param _handlerMetadata - The handler metadata containing configuration. * @returns An empty schema object. */ provideSchema(_handlerMetadata: HandlerMetadata): Record; /** * Builds response headers with Content-Type: application/json. */ protected buildHeaders(context: HandlerContext): Record; /** * Creates a static handler for singleton controllers. * * @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. * * @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; /** * Builds a response formatter with optional schema validation. */ protected buildResponseFormatter(context: HandlerContext): (result: any) => any; } //#endregion //#region src/adapters/multipart-adapter.service.d.mts /** * Injection token for the Bun multipart adapter service. * * This token is used to inject the `BunMultipartAdapterService` instance * into the dependency injection container. */ declare const BunMultipartAdapterToken: InjectionToken; /** * Adapter service for handling multipart/form-data requests in Bun. * * This service extends `BunEndpointAdapterService` and provides specialized * handling for file uploads and multipart form data. It automatically parses * FormData objects, handles file uploads, and validates the data against * Zod schemas. * * @extends {BunEndpointAdapterService} * * @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 BunMultipartAdapterService extends BunEndpointAdapterService { /** * 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 FormData * * Files are preserved as File objects, and form fields are parsed and * validated against the request schema. * * @param handlerMetadata - The handler metadata with schemas and configuration. * @returns An array of getter functions that populate request arguments. */ protected createArgumentGetters(handlerMetadata: HandlerMetadata): ArgumentGetter[]; /** * Parses FormData into a plain object with array support for multiple values. */ private parseFormData; } //#endregion //#region src/utils/cors.util.d.mts /** * Function type for dynamic origin validation. * Called with the request origin and a callback to return the validation result. */ type OriginFunction = (origin: string | undefined, callback: (error: Error | null, allow?: boolean | string) => void) => void; /** * Extended CORS options for the Bun adapter. * Extends the core AbstractHttpCorsOptions with support for function-based origin. */ interface BunCorsOptions extends Omit { /** * Configures the Access-Control-Allow-Origin CORS header. * Can be a string, boolean, RegExp, array of these, or a function for dynamic validation. */ origin?: string | boolean | RegExp | (string | boolean | RegExp)[] | OriginFunction; } /** * CORS headers that can be set on a response. */ interface CorsHeaders { 'Access-Control-Allow-Origin'?: string; 'Access-Control-Allow-Credentials'?: string; 'Access-Control-Expose-Headers'?: string; 'Access-Control-Allow-Headers'?: string; 'Access-Control-Allow-Methods'?: string; 'Access-Control-Max-Age'?: string; 'Cache-Control'?: string; Vary?: string; } /** * Calculates CORS headers for a request based on the provided options. * * @param requestOrigin - The Origin header from the request * @param options - CORS configuration options * @returns CORS headers object or null if origin is not allowed */ declare function calculateCorsHeaders(requestOrigin: string | undefined, options: BunCorsOptions): Promise; /** * Calculates CORS headers specifically for preflight (OPTIONS) requests. * * @param requestOrigin - The Origin header from the request * @param requestMethod - The Access-Control-Request-Method header * @param requestHeaders - The Access-Control-Request-Headers header * @param options - CORS configuration options * @returns CORS headers object or null if origin is not allowed */ declare function calculatePreflightHeaders(requestOrigin: string | undefined, requestMethod: string | null, requestHeaders: string | null, options: BunCorsOptions): Promise; /** * Checks if a request is a CORS preflight request. * * @param method - The HTTP method of the request * @param origin - The Origin header value * @param accessControlRequestMethod - The Access-Control-Request-Method header * @returns true if this is a preflight request */ declare function isPreflight(method: string, origin: string | null, accessControlRequestMethod: string | null): boolean; /** * Applies CORS headers to a Response object. * * @param response - The original response * @param requestOrigin - The Origin header from the request * @param options - CORS configuration options * @returns A new Response with CORS headers, or the original if origin not allowed */ declare function applyCorsToResponse(response: Response, requestOrigin: string | null, options: BunCorsOptions | null): Promise; //#endregion //#region src/interfaces/environment.interface.d.mts /** * Environment interface for the Bun HTTP adapter. * * Provides type-safe access to Bun-specific types when using * `NaviosApplication`. * * @example * ```typescript * import { defineBunEnvironment, BunEnvironment } from '@navios/adapter-bun' * import { NaviosFactory } from '@navios/core' * * const app = await NaviosFactory.create(AppModule, { * adapter: defineBunEnvironment(), * }) * * // All methods are now type-safe for Bun * app.configure({ development: true }) * app.enableCors({ origin: true }) // BunCorsOptions * const server = app.getServer() // Server * await app.listen({ port: 3000 }) // BunListenOptions * ``` */ interface BunEnvironment extends HttpAdapterEnvironment { /** Bun.Server instance */ server: Server; /** BunCorsOptions for CORS configuration */ corsOptions: BunCorsOptions; /** Multipart is handled natively by Bun */ multipartOptions: never; /** BunListenOptions for server listen configuration */ listenOptions: BunListenOptions; /** BunApplicationOptions for server setup */ options: BunApplicationOptions; /** BunApplicationServiceInterface for the Bun application service */ adapter: BunApplicationServiceInterface; } //#endregion //#region src/interfaces/application.interface.d.mts /** * Configuration options for the Bun HTTP server. * * Extends Bun's native `Serve.Options` with additional Navios-specific * configuration options. These options are passed to `Bun.serve()` when * the server is started. * * @example * ```ts * app.configure({ * development: process.env.NODE_ENV === 'development', * maxRequestBodySize: 1024 * 1024, // 1MB * }) * ``` * * @see {@link https://bun.sh/docs/api/http} Bun HTTP server documentation */ type BunApplicationOptions = Omit, 'port' | 'hostname' | 'routes' | 'fetch'> & { /** * 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 */ logger?: LoggerService | LogLevel[] | false; }; /** * Options for starting the Bun HTTP server. * * These options control where and how the server listens for incoming requests. * * @example * ```ts * await app.listen({ * port: 3000, * hostname: '0.0.0.0', // Listen on all interfaces * }) * ``` */ interface BunListenOptions { /** * The port number to listen on. * * @default 3000 */ port?: number; /** * The hostname or IP address to bind to. * * Use `'0.0.0.0'` to listen on all network interfaces, * or `'localhost'` to only accept local connections. * * @default 'localhost' */ hostname?: string; } /** * Interface for the Bun application service. * * This interface defines the contract for the Bun HTTP adapter service, * extending the base `AbstractHttpAdapterInterface` with Bun-specific * methods and types. * * @extends {AbstractHttpAdapterInterface} * * @example * ```ts * const app = await NaviosFactory.create(AppModule, { * adapter: defineBunEnvironment(), * }) * * await app.init() * await app.listen({ port: 3000 }) * ``` */ interface BunApplicationServiceInterface extends AbstractHttpAdapterInterface { initServer(): Promise; } //#endregion //#region src/interfaces/bun-fake-reply.interface.d.mts /** * A fake reply object for the Bun adapter that collects response information. * * Since Bun uses the standard Web API Response object instead of a mutable reply, * this class provides a way to capture status and body information from guards * and other middleware that expect a reply object with `.status().send()` interface. * * After guards run, the collected information can be used to construct a Response object. * * @example * ```ts * const fakeReply = new BunFakeReply() * const context = new BunExecutionContext(module, controller, handler, request, fakeReply) * * await guardRunner.runGuards(guards, context, container) * * if (fakeReply.hasResponse()) { * return fakeReply.toResponse() * } * // Continue with normal request handling... * ``` */ declare class BunFakeReply { private _statusCode; private _body; private _sent; private _headers; /** * Sets the HTTP status code for the response. * Returns `this` for chaining. * * @param code - The HTTP status code. * @returns This instance for method chaining. */ status(code: number): this; /** * Sets the response body and marks the response as sent. * * @param body - The response body (will be JSON stringified if not a string). */ send(body: unknown): void; /** * Sets a response header. * Returns `this` for chaining. * * @param name - The header name. * @param value - The header value. * @returns This instance for method chaining. */ header(name: string, value: string): this; /** * Checks if a response has been sent via this fake reply. * * @returns `true` if `send()` was called, `false` otherwise. */ hasResponse(): boolean; /** * Gets the collected status code. */ getStatusCode(): number; /** * Gets the collected body. */ getBody(): unknown; /** * Converts the collected information into a Web API Response object. * * @returns A Response object with the collected status, body, and headers. */ toResponse(): Response; /** * Resets the fake reply to its initial state. * Useful for reusing the same instance. */ reset(): void; } //#endregion //#region src/interfaces/bun-execution-context.interface.d.mts /** * Execution context for Bun adapter requests. * * This class provides access to metadata about the current request's * module, controller, handler, and request object. It's used by guards, * interceptors, and other request-scoped services to access context * information. * * @implements {AbstractExecutionContext} * * @example * ```ts * @Injectable() * class AuthGuard implements CanActivate { * canActivate(context: BunExecutionContext): boolean { * const request = context.getRequest() * const handler = context.getHandler() * // Check authentication based on handler metadata * return true * } * } * ``` */ declare class BunExecutionContext 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: Request, reply?: BunFakeReply | undefined); /** * 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 HTTP request object. * * @returns The Bun Request object for the current request. * @throws {Error} If the request is not set. */ getRequest(): Request; /** * Gets the reply object for this execution context. * * In the Bun adapter, this returns a `BunFakeReply` object that collects * response information from guards and middleware. The collected information * can be used to construct a Response object after guards run. * * @returns The BunFakeReply object if one was provided, otherwise throws. * @throws {Error} If no reply was set in the execution context. */ getReply(): BunFakeReply; } //#endregion //#region src/services/controller-adapter.service.d.mts /** * 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. */ 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 {} * ``` */ 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; } //#endregion //#region src/services/application.service.d.mts /** * Bun HTTP adapter service implementation for Navios. * * This service provides the core HTTP server functionality for Navios applications * running on the Bun runtime. It handles server initialization, route registration, * request handling, and server lifecycle management. * * @example * ```ts * const app = await NaviosFactory.create(AppModule, { * adapter: defineBunEnvironment(), * }) * * app.configure({ development: true }) * await app.init() * await app.listen({ port: 3000, hostname: '0.0.0.0' }) * ``` * * @implements {BunApplicationServiceInterface} */ declare class BunApplicationService implements BunApplicationServiceInterface { private logger; protected container: Container; private errorProducer; private server; private controllerAdapter; private globalPrefix; private routes; private serverOptions; private corsOptions; private configureOptions; /** * app.configure({ * development: process.env.NODE_ENV === 'development', * maxRequestBodySize: 1024 * 1024, // 1MB * }) * await app.init() * ``` */ setupAdapter(options: unknown): Promise; /** * Initializes the Bun server instance and registers it in the dependency injection container. * * This method is called automatically during the application initialization process. * It makes the server instance available for injection via `BunServerToken`. * * @throws {Error} If the server has not been created yet. */ initServer(): Promise; /** * Marks the server as ready. * * For Bun, the server is ready immediately upon creation, so this is a no-op. */ 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 Bun server instance. * * This allows direct access to the Bun server for advanced use cases, * such as WebSocket upgrades or custom middleware. * * @returns The Bun server instance. * @throws {Error} If the server has not been initialized yet. * * @example * ```ts * const server = app.getServer() * // Access Bun-specific server methods * ``` */ getServer(): Server; onModulesInit(modules: Map): Promise; /** * Fallback request handler for unmatched routes and CORS preflight. * * Handles: * - CORS preflight (OPTIONS) requests * - 404 responses for unmatched routes with CORS headers * * @param request - The incoming request * @returns A Response with appropriate status and CORS headers * @private */ private handleRequest; /** * Enables CORS (Cross-Origin Resource Sharing) support. * * Configures CORS headers for all routes. The options are applied when * handling requests. * * @param options - CORS configuration options. * * @example * ```ts * app.enableCors({ * origin: true, // Allow all origins * methods: ['GET', 'POST', 'PUT', 'DELETE'], * credentials: true, * }) * ``` */ enableCors(options: BunCorsOptions): void; /** * Enables multipart form data support. * * @param _options - Multipart options (not currently supported in Bun adapter). * @deprecated Multipart support is handled automatically by Bun's native FormData support. */ enableMultipart(): void; /** * Starts the Bun HTTP server and begins listening for incoming requests. * * This method creates and starts the Bun 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 hostname. * @returns A promise that resolves to a string in the format `hostname:port` * indicating where the server is listening. * * @example * ```ts * const address = await app.listen({ * port: 3000, * hostname: '0.0.0.0', * }) * console.log(`Server listening on ${address}`) * ``` */ listen(options: any): 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 Bun server configuration options * * @example * ```ts * app.configure({ development: true }) * await app.init() * ``` */ configure(options: Partial): void; /** * Gracefully shuts down the Bun server. * * This method stops the server 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/tokens/controller-adapter.token.d.mts /** * Injection token for BunControllerAdapterService. * * This token allows overriding the default controller adapter with custom * implementations (e.g., for tracing or other middleware-like behavior). */ declare const BunControllerAdapterToken: InjectionToken$1; //#endregion //#region src/tokens/request.token.d.mts /** * Injection token for the current Bun 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(BunRequestToken) * * getUrl() { * return this.request.url * } * * getMethod() { * return this.request.method * } * } * ``` */ declare const BunRequestToken: InjectionToken; //#endregion //#region src/tokens/server.token.d.mts /** * Injection token for the Bun server instance. * * This token provides access to the underlying Bun server instance, * allowing direct interaction with Bun's server API for advanced use cases * such as WebSocket upgrades or custom server configuration. * * @example * ```ts * @Injectable() * class WebSocketService { * private server = inject(BunServerToken) * * upgrade(request: Request) { * // Use server instance for WebSocket upgrades * return this.server.upgrade(request) * } * } * ``` */ declare const BunServerToken: InjectionToken, undefined, false>; //#endregion //#region src/tokens/bun-application.token.d.mts /** * Injection token for the Bun application service. * * This token is used to inject the `BunApplicationService` 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(BunApplicationServiceToken) * * getServer() { * return this.appService.getServer() * } * } * ``` */ declare const BunApplicationServiceToken: InjectionToken; //#endregion //#region src/define-environment.d.mts /** * Creates a Bun adapter environment configuration for Navios. * * This function sets up the necessary dependency injection tokens and services * required to run Navios applications on the Bun 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 token for accessing the current Bun request * * @returns An object containing the token mappings for the Bun adapter. * This object should be passed to `NaviosFactory.create()` as the `adapter` option. * * @example * ```ts * import { defineBunEnvironment } from '@navios/adapter-bun' * import { NaviosFactory } from '@navios/core' * * const app = await NaviosFactory.create(AppModule, { * adapter: defineBunEnvironment(), * }) * ``` * * @example * ```ts * // With custom Bun server options * const app = await NaviosFactory.create(AppModule, { * adapter: defineBunEnvironment(), * }) * * app.configure({ * development: process.env.NODE_ENV === 'development', * }) * await app.init() * ``` * * @see {@link BunApplicationService} The HTTP adapter service implementation * @see {@link BunEndpointAdapterService} The endpoint adapter implementation * @see {@link BunStreamAdapterService} The stream adapter implementation * @see {@link BunMultipartAdapterService} The multipart adapter implementation */ declare function defineBunEnvironment(): { tokens: Map, AnyInjectableType>; }; //#endregion export { BunApplicationOptions, BunApplicationService, BunApplicationServiceInterface, BunApplicationServiceToken, BunControllerAdapterService, BunControllerAdapterToken, BunCorsOptions, BunDynamicHandler, BunEndpointAdapterService, BunEndpointAdapterToken, BunEnvironment, BunExecutionContext, BunFakeReply, BunHandlerAdapterInterface, BunHandlerResult, BunListenOptions, BunMultipartAdapterService, BunMultipartAdapterToken, BunRequestToken, BunRoutes, BunServerToken, BunStaticHandler, BunStreamAdapterService, BunStreamAdapterToken, CorsHeaders, OriginFunction, applyCorsToResponse, calculateCorsHeaders, calculatePreflightHeaders, defineBunEnvironment, isPreflight }; //# sourceMappingURL=index.d.cts.map