/** * This file contains the implementation of the Bun application adapter for EcoPages. * It extends the AbstractApplicationAdapter class and provides methods for handling * HTTP requests, initializing the server adapter, and starting the Bun application server. * The adapter is designed to work with the Bun runtime and provides a way to create * EcoPages applications using Bun's features. * * @module EcopagesApp */ import type { Server } from 'bun'; import type { ApiHandlerContext, EcopagesRouteInfo, RouteGroupBuilder } from '../../types/public-types.js'; import { SharedApplicationAdapter } from '../shared/runtime/application-adapter.js'; import type { RuntimeHost } from '../shared/runtime/runtime-host.js'; import type { EcopagesAppOptions } from '../create-app.js'; import { type BunServerAdapterResult } from './server-adapter.js'; /** * Bun-specific route group builder that properly infers route params from path patterns. * When you define a route like `/posts/:slug`, the handler context will have * `ctx.params.slug` typed as `string`. * * @typeParam WebSocketData - WebSocket data type for the server * @typeParam TContext - Extended context type from middleware (e.g., `{ user: User }`) */ export type BunRouteGroupBuilder> = ApiHandlerContext>> = RouteGroupBuilder, TContext>; /** * Bun-specific application adapter implementation * This class extends the {@link AbstractApplicationAdapter} * and provides methods for handling HTTP requests and managing the server. */ export declare class BunEcopagesApp extends SharedApplicationAdapter, Request> { serverAdapter: BunServerAdapterResult | undefined; private server; private stopped; private readonly runtimeHost; constructor(options: EcopagesAppOptions, dependencies: { runtimeHost: RuntimeHost, Bun.Serve.Options>; }); fetch(request: Request): Promise; attachWebSocketUpgrades(httpServer: import('node:http').Server, options?: { passthroughUnmatched?: boolean; }): Promise; /** * Complete the initialization of the server adapter by processing dynamic routes * @param server The Bun server instance */ completeInitialization(server: Server): Promise; /** * Initialize the Bun server adapter */ protected initializeServerAdapter(): Promise; /** * Start the Bun application server * @param options Optional settings * @param options.autoCompleteInitialization Whether to automatically complete initialization with dynamic routes after server start (defaults to true) */ protected bootServer(): Promise | void>; stop(force?: boolean): Promise; protected resolveAppRoutes(): Promise; } /** * Factory function to create a Bun application */ export declare function createApp(options: EcopagesAppOptions): Promise>;