RPC client for Node
Purpose
RPC client factory, returning a RequestRPC
instance using the HTTP transport if the provided endpoint
is a HTTP URL, or a StreamRPC
instance using the WebSocket transport if the provided endpoint
is a WebSocket URL or the IPC transport if the provided endpoint
is a socket path.
Installation
npm install @erebos/rpc-node
Usage
import { createRPC } from '@erebos/rpc-node'
const rpcOverHTTP = createRPC('http://localhost') // RequestRPC using HTTP transport
const rpcOverWS = createRPC('ws://localhost') // StreamRPC using WebSocket transport
const rpcOverIPC = createRPC('/path/to/socket') // StreamRPC using ICP transport
API
createRPC()
Arguments
endpoint: string
: socket path, HTTP or WebSocket URL to connect to.
Returns RequestRPC
(with HTTP endpoint) or StreamRPC
(with IPC path or WebSocket endpoint).