rpc-end
v1.0.0
Published
Transport-agnostic RPC library with request-response and notifications
Maintainers
Readme
RPC End
Transport-agnostic RPC library with request-response and notifications
A lightweight, type-safe RPC framework for Node.js that supports multiple transport layers, promise-based API, and comprehensive error handling.
Features
- 🚀 Transport-agnostic - Works with any transport (IPC, WebSocket, HTTP, custom channels)
- 📡 Request-Response - Traditional RPC pattern with type-safe responses
- 🔔 Notifications - Fire-and-forget messages without expecting responses
- 🔒 Type-Safe - Full TypeScript support with strict typing
- ⏱️ Timeout Handling - Configurable timeouts for RPC calls
- 🔄 Promise-based API - Modern async/await interface
- 🧩 Pluggable - Easily extend with custom transports
- 🛡️ Error Handling - Comprehensive error propagation with stack traces
- 📦 Zero Dependencies - Lightweight and fast
Installation
npm install rpc-endBasic Usage with IPC
import { Rpc, IpcChannel } from 'rpc-end';
import { fork } from 'node:child_process';
// Parent process
const child = fork('./child.js');
const channel = new IpcChannel('my-channel', child);
const rpc = new Rpc(channel);
// Call remote method
const result = await rpc.call('add', { a: 5, b: 3 });
console.log(result); // 8
// Send notification
rpc.notify('log', { level: 'info', message: 'Hello' });// child.js
import { Rpc, IpcChannel } from 'rpc-end';
const channel = new IpcChannel('my-channel', process);
const rpc = new Rpc(channel);
// Register methods
rpc.register('add', async (data) => {
return data.a + data.b;
});
rpc.register('greet', async (data) => {
return `Hello, ${data.name}!`;
});
// Keep process alive
process.stdin.resume();Documentation
For complete API reference, see API documentation.
