@sproutboat/wire
v0.9.1
Published
Broker frame protocol and the JSON validation utilities it is built on. Single source of truth shared by the CLI dev broker and the platform's edge and supervisor.
Readme
@sproutboat/wire
Broker frame protocol and the JSON validation utilities it is built on. Single source of truth shared by the CLI dev broker and the platform's edge and supervisor.
bun add @sproutboat/wireimport { createBroker } from "@sproutboat/wire";
import { parseJsonValue } from "@sproutboat/wire";API
createBroker(options)opens a binding broker over a resource file: KV, D1, R2, queues, Durable Object storage and alarms, Analytics Engine points, secrets, outbound fetch. Frame envelope, both directions:[u32 LE length][payload].- Frame helpers:
frameOf,encodeFrame,encodeV1,FRAME_V1,cronMatches, plus theBroker,BrokerOptions,BrokerServer,FetchLikeandFrametypes. - JSON boundary parsing:
parseJsonValue,jsonObject, guards (isString,isBoolean,isSafeInteger),JsonValueandJsonObjecttypes. Parse at the I/O boundary, then narrow; nothing downstream takes an unparsed value.
See src/broker.test.ts for the protocol contract in executable form.
