Classes

c
BunHttpAdapter(
host?: BunServeHost,
options?: HttpAdapterOptions
)

Bun HTTP adapter implementation.

c
CloudflareWorkersHttpAdapter(
wsHost?: CloudflareWebSocketHost,
options?: HttpAdapterOptions
)

Cloudflare Workers HTTP adapter implementation.

c
DenoHttpAdapter(
host?: DenoServeHost,
options?: HttpAdapterOptions
)

Deno HTTP adapter implementation.

c
NodeHttpAdapter(
host?: NodeServeHost,
wsModule?: WsModuleLike,
options?: HttpAdapterOptions
)

Node HTTP adapter implementation.

c
NodeUpgradeCoordinator(module?: WsModuleLike)

Owns the ws server for one Node HTTP adapter and performs the handshake.

c
RequestBodyTooLargeError(maxBodyBytes: number)

Raised when a request body exceeds the configured RuntimeOptions.maxBodyBytes cap.

c
RpcInterceptorStore

Stores an adapter's RPC interceptor and consults it safely.

Functions

f
adaptWsModule(module: unknown): WsModuleLike

Narrows an already-imported module to WsModuleLike.

f
asUpgradeEmitter(server: unknown): UpgradeEmitter | null

Probes a server handle for the raw upgrade event.

f
buildBunHost(mods?: BunModules): BunHost

Builds the default BunHost from node: built-ins, which Bun implements.

f
buildNodeHost(mods?: NodeModules): NodeHost

Builds the default NodeHost from node: built-ins, which Deno and Bun also implement.

f
createBunWebSocketHandlers(): BunWebSocketHandlers

Builds the serve-time handler object that routes every Bun socket event to the sink stored on that socket's data.

f
createDefaultCloudflareWebSocketHost(): CloudflareWebSocketHost

Builds the default host from the real Workers globals.

f
createDenoDnsResolver(host: DenoDnsHost): IDnsResolver

Creates an IDnsResolver backed by Deno.resolveDns.

f
createNodeDnsResolver(dns?: NodeDnsModule): IDnsResolver

Creates an IDnsResolver backed by node:dns/promises.

f
createNodeWorkerHost(mods?: NodeWorkerModules): IWorkerHost

Creates an IWorkerHost backed by node:worker_threads.

f
createUpgradeRequest(incoming: NodeIncomingMessage): Request

Reconstructs a web-standard Request from Node's upgrade event arguments, so the upgrade router sees the same shape on every runtime.

f
createWebSocketTransport(socket: WebSocketLike): IWebSocketTransport

Wraps a web-API socket as an IWebSocketTransport.

f
createWebWorkerHost(
globals?: WebWorkerGlobals,
options?: WebWorkerHostOptions
): IWorkerHost

Creates an IWorkerHost backed by the web-standard Worker API (Deno and Bun).

f
createWsTransport(socket: WsSocketLike): IWebSocketTransport

Wraps a ws socket as an IWebSocketTransport.

f
detectRuntime(globals?: GlobalScope): RuntimePlatform

Detects the current runtime platform.

f
isWebSocketUpgradeRequest(headers: Headers): boolean

Reports whether a set of request headers describes an RFC 6455 WebSocket upgrade.

f
loadWsModule(): Promise<WsModuleLike>

Lazily imports ws and narrows it.

f
normalizeFrame(data: unknown): string | Uint8Array

Normalizes an inbound frame payload to the framework's string | Uint8Array.

f
rejectRawUpgrade(
socket: RawUpgradeSocket,
status: number
): void

Refuses an upgrade on the raw socket, since there is no Response object to return on Node's upgrade path.

f
RuntimePlugin(options?: RuntimeOptions): IPlugin

Creates the RuntimePlugin that provides runtime-agnostic services and HTTP adapter.

f
toReadyState(state: number): WebSocketReadyState

Maps the web WebSocket API's numeric readyState to the framework's named WebSocketReadyState.

f
toTransportError(value: unknown): Error

Coerces an error-event payload into a real Error.

f
toWsReadyState(state: number): WebSocketReadyState

Maps a ws numeric ready state to the framework's named state.

Interfaces

I
BunHost

Minimal interface covering the Bun-specific operations used by this adapter. Inject this interface to test the adapter without real Bun.

I
BunModules

The built-ins buildBunHost needs, injectable so every wrapper is unit-testable without real file-system access. Shapes match node:fs (sync), node:os, and node:process, all of which Bun implements.

I
BunServeHost

Minimal interface covering the Bun-specific HTTP operations used by this adapter. Inject this interface to test the adapter without real Bun.

I
BunServer

Bun server handle (from Bun.serve).

I
BunServerWebSocket

A Bun ServerWebSocket, narrowed to what this adapter drives.

I
BunSocketData

The per-socket data Bun carries from server.upgrade() through to every socket handler.

I
BunWebSocketHandlers

The serve-time socket handler object Bun expects under Bun.serve's websocket option.

I
CloudflareEnv

Injectable environment seam for Cloudflare Workers bindings. Defaults to an empty record so the adapter is testable without Workers globals.

I
CloudflareRuntimeOptions
  • env: CloudflareEnv

    Injectable env source for reading Workers bindings. Defaults to an empty record.

I
CloudflareServerSocket

The server half of a Workers WebSocketPair. Workers sockets are driven with addEventListener after an explicit accept(), not with on* properties.

I
CloudflareWebSocketHost

Injectable seam covering the two Workers-only globals this upgrader needs.

I
CloudflareWebSocketPair

A created WebSocketPair: the client half travels back in the 101 response, the server half stays here.

I
CreateRuntimeServicesOptions

Options for createRuntimeServices.

I
DenoDirEntry

Directory entry returned by DenoHost.readdir().

I
DenoDnsHost

The Deno.resolveDns surface this resolver needs.

I
DenoHost

Minimal interface covering the Deno-specific operations used by this adapter. Inject this interface to test the adapter without real Deno.

I
DenoServeHost

Minimal interface covering the Deno operations this adapter needs. Inject this interface to test the adapter without real Deno.

I
DenoServer

Deno HTTP server handle (from Deno.serve).

I
DenoSrvRecord

One SRV record as Deno.resolveDns returns it.

I
DenoWebSocketLike

A web-API socket that exposes the on* handler properties, as Deno's upgradeWebSocket socket does.

I
DenoWebSocketUpgrade

The result shape of Deno.upgradeWebSocket.

I
GlobalScope

Minimal global scope shape needed for detection. Allows injecting a fake global for testing without as casts in test code.

I
HttpAdapterOptions

Options every IHttpAdapter implementation in this package accepts, supplied by RuntimePlugin when it constructs one.

  • maxBodyBytes: number

    Maximum request-body size, in bytes, enforced where the body is actually read. Omitted, the read is unbounded — the released behaviour.

I
NodeDnsModule

The node:dns/promises surface this resolver needs, injectable so every branch is unit-testable without real DNS or network permission.

I
NodeHost

Minimal interface covering the Node-specific operations used by this adapter. Inject this interface to test the adapter without real Node.js.

I
NodeIncomingMessage

A Node IncomingMessage, narrowed to what building an upgrade Request needs.

I
NodeModules
I
NodeServeHost

Minimal interface covering the @hono/node-server serve() operation. Inject this interface to test the adapter without a real Node server.

I
NodeServer

Node.js HTTP server handle (returned by @hono/node-server serve()).

I
NodeWorkerLike

Minimal shape of a node:worker_threads Worker as used by this host.

I
NodeWorkerModules

The Node built-ins this host needs. Inject fakes to test without real threads.

I
RawUpgradeSocket

The raw socket handed to a Node upgrade listener, narrowed to what a refusal needs.

I
RuntimeAdapterFactories

Map of platform → runtime adapter factory.

I
RuntimeOptions

Options for RuntimePlugin.

  • adapters: RuntimeAdapterFactories

    Override runtime adapter factories for testing. When provided, the plugin uses these instead of the real adapter factories, allowing unit tests to run without OS permissions or real runtime globals.

  • env: Readonly<Record<string, unknown>>

    The Cloudflare Workers env record. There is no ambient environment on the edge, so without this runtime.env is empty on Workers and ConfigPlugin reads nothing.

  • httpAdapters: HttpAdapterFactories

    Override HTTP adapter factories for testing. When provided, the plugin uses these instead of the default HTTP adapters, allowing unit tests to inject fake HTTP adapters.

  • maxBodyBytes: number

    Maximum request-body size, in bytes, enforced where the body is read. Omitted, the read is unbounded — the released behaviour, byte for byte.

  • platform: RuntimePlatform

    Force a specific platform instead of auto-detecting. Useful for testing or when running in an environment where detection might be ambiguous.

I
UpgradeEmitter

An event emitter that can report raw HTTP upgrades — the one capability this adapter needs from the node:http server that serve() returns.

I
WebSocketLike

The subset of the web WebSocket API the runtime adapters drive. Declared structurally so no module depends on a platform's global types and a fake can stand in during unit tests.

I
WebWorkerGlobals

The web globals this host needs. Inject fakes to test without spawning real workers.

I
WebWorkerHostOptions

Host-construction options that vary between the runtimes sharing this implementation.

  • exitEventName: string

    Name of the non-standard event this runtime emits when a worker's thread ends. Bun emits 'close'; Deno emits nothing at all, so it passes nothing and the handles this host produces omit onExit entirely.

I
WebWorkerLike

Minimal shape of a web Worker instance as used by this host.

I
WsServerLike

A ws WebSocketServer in noServer mode, narrowed to what this adapter drives.

I
WsSocketLike

A ws socket, narrowed to what this adapter drives. Declared structurally so the package never takes a type dependency on @types/ws.

Usage

import * as RuntimePlugin_and_runtime_adapters_providing___linkcode_IRuntimeServices__for_Node_js__Deno__Bun__and_Cloudflare_Workers__HTTP_server_adapters_are_also_provided_for_running_the_framework_on_real_HTTP_servers___Every_export_is_documented_in_PUBLIC_API_md_section_36_ from "runtime/src/index.ts";