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

38 lines 1.41 kB
/** * @ws-kit/bun - Bun WebSocket server adapter * * Bun-specific adapter providing: * - `bunPubSub()` factory for Bun Pub/Sub integration via plugins * - `createBunHandler()` factory for Bun.serve integration * - `serve()` high-level convenience function for starting a server * - Zero-copy message broadcasting and native backpressure handling * * @example High-level (quick start) * ```typescript * import { serve } from "@ws-kit/bun"; * import { createRouter } from "@ws-kit/zod"; * * const router = createRouter(); * serve(router, { port: 3000 }); * ``` * * @example With Pub/Sub plugin * ```typescript * import { createRouter } from "@ws-kit/zod"; * import { withPubSub } from "@ws-kit/pubsub"; * import { bunPubSub, createBunHandler } from "@ws-kit/bun"; * * const server = Bun.serve({...}); * const router = createRouter() * .plugin(withPubSub({ adapter: bunPubSub(server) })); * * const { fetch, websocket } = createBunHandler(router); * ``` */ export { bunPubSub } from "./adapter.js"; export { createBunHandler } from "./handler.js"; export { serve } from "./serve.js"; export { adaptBunWebSocket, isBunWebSocket } from "./websocket.js"; export type { BunServeOptions } from "./serve.js"; export type { AuthRejection, BunConnectionContext, BunConnectionData, BunErrorEvent, BunHandlerOptions, BunServerHandlers, } from "./types.js"; //# sourceMappingURL=index.d.ts.map