Registry / communication / bridgewire

bridgewire

JSON →
library2.0.2jsnpmunverified

Transport-agnostic client for HTTP and WebSocket communication with a fluent builder API. Version 2.0.2, actively developed. Supports fetch and WebSocket transports, typed request/response data, lifecycle events (message, error, abort, settled), timeouts, content-type based parsing, and explicit payload type selection. Differentiates by offering a unified builder pattern for multiple transports and lifecycle hooks.

npm install bridgewire
INSTALL
IMPORT
SIG · BRIDGEWIRE
B
bridgewire
communicationjavascriptv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getBridgeWireBuilder
import getBridgeWireBuilder, { HTTPMethod, PayloadDataType, Protocol, TransportType } from 'bridgewire';
const getBridgeWireBuilder = require('bridgewire');
ESM-only, named exports for enums/types.
HTTPMethod
import { HTTPMethod } from 'bridgewire';
import HTTPMethod from 'bridgewire';
Named export, not default.
TransportType
import { TransportType } from 'bridgewire';
import { Transport } from 'bridgewire';
Named export, exact name.
PayloadDataType
import { PayloadDataType } from 'bridgewire';
Named export.

Builds a GET fetch transport with typed query parameters and response, subscribes to messages, and sends a request.

import getBridgeWireBuilder, { HTTPMethod, PayloadDataType, Protocol, TransportType } from 'bridgewire'; type UserQuery = { id: string }; type UserResponse = { id: string; name: string }; const transport = getBridgeWireBuilder<UserQuery, UserResponse>() .withTransport(TransportType.FETCH) .withProtocol(Protocol.HTTPS) .withHost('api.example.com') .withPath('/users') .withMethod(HTTPMethod.GET) .withDataType(PayloadDataType.JSON) .build(); transport.onMessage((id, data) => { console.log('Message:', id, data); }); const request = transport.send({ id: '42' }); console.log(request?.status);
Debug
Known issues
breakingDefault export changed from function to named export getBridgeWireBuilder in v2.0.
fix
Use `import getBridgeWireBuilder from 'bridgewire'` (default export) for v2+; older versions may have different export.
affects: <2.0
gotchaEnums are runtime objects, not just types; tree-shaking may not eliminate them.
fix
Ensure bundler is configured to handle side-effect-free enums or import only needed values.
affects: *
gotchaWebSocket transport does not support request-level method/headers as it's a full-duplex channel.
fix
Do not call .withMethod() or .withHeader() when using TransportType.WEBSOCKET.
affects: *
Errors
Common errors & fixes
Cannot find module 'bridgewire' or its corresponding type declarations.
Package not installed or missing tsconfig paths.
fix
Run `npm install bridgewire` and ensure tsconfig 'esModuleInterop' and 'moduleResolution' are set (e.g., bundler or node16).
Uncaught TypeError: bridgewire is not a function
Using CommonJS require instead of ESM import.
fix
Replace `const bridgewire = require('bridgewire')` with `import getBridgeWireBuilder from 'bridgewire'`.
TypeError: withTransport is not a function
Chaining after .build() or using wrong import (e.g., importing a non-builder object).
fix
Ensure you call getBridgeWireBuilder() first, then chain builder methods, and call .build() last.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
bridgewire — npm install bridgewire · libregistry