UNPKG

@ws-kit/bun

Version:

Bun platform adapter for WS-Kit leveraging native WebSocket API with built-in pub/sub and low-latency message routing

42 lines 1.47 kB
/** * @ws-kit/bun - Bun serve function * * High-level convenience wrapper for serving a router on Bun. */ import type { ConnectionData, Router } from "@ws-kit/core"; import type { BunHandlerOptions } from "./types.js"; /** * Options for the serve function. * * Extends BunHandlerOptions with Bun-specific server config. * Per ADR-035, only mechanical options (auth, lifecycle) are supported. * Behavioral concerns (context, observability) belong in plugins. */ export interface BunServeOptions<TContext extends ConnectionData = ConnectionData> extends BunHandlerOptions<TContext> { /** * Port to listen on. * @default 3000 */ port?: number; } /** * Serve a router on Bun. * * High-level convenience function that creates a WebSocket handler and starts * a Bun HTTP server. For more control, use `createBunHandler()` directly. * * @param router - The WebSocket router to serve * @param options - Server options * @returns Promise that resolves when server is running (never completes) * * @example * ```typescript * import { serve } from "@ws-kit/bun"; * import { createRouter } from "@ws-kit/zod"; * * const router = createRouter(); * serve(router, { port: 3000 }); * ``` */ export declare function serve<TContext extends ConnectionData = ConnectionData, TExtensions extends object = any>(router: Router<TContext, TExtensions>, options?: BunServeOptions<TContext>): Promise<void>; //# sourceMappingURL=serve.d.ts.map