npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gnana997/node-jsonrpc

v1.0.0

Published

Transport-agnostic JSON-RPC 2.0 client and server for TypeScript/Node.js

Readme

@gnana997/node-jsonrpc

Transport-agnostic JSON-RPC 2.0 client and server for TypeScript/Node.js

npm version CI License: MIT

Features

  • Transport Agnostic - Works with IPC, stdio, HTTP, WebSocket, or any custom transport
  • Full JSON-RPC 2.0 - Complete spec compliance for client and server
  • TypeScript First - Fully typed with excellent IntelliSense support
  • Zero Dependencies - Only uses Node.js standard library
  • Middleware Support - Intercept and modify requests/responses
  • Batch Requests - Send multiple requests in a single round-trip
  • Request Cancellation - AbortSignal support for cancelling requests
  • Debug Logging - Built-in logger with configurable levels
  • Bidirectional - Server can send notifications to clients
  • Multi-Client - Server handles multiple concurrent connections
  • Well Tested - Comprehensive test suite with 80%+ coverage

Installation

npm install @gnana997/node-jsonrpc

Quick Start

Client

import { JSONRPCClient } from '@gnana997/node-jsonrpc';
import { MyTransport } from './my-transport'; // Your transport implementation

const client = new JSONRPCClient({
  transport: new MyTransport(),
});

await client.connect();

// Make a request
const result = await client.request('subtract', { minuend: 42, subtrahend: 23 });
console.log(result); // 19

// Send a notification (no response)
client.notify('update', { status: 'ready' });

// Listen for server notifications
client.on('notification', (method, params) => {
  console.log(`Server sent ${method}:`, params);
});

Server

import { JSONRPCServer } from '@gnana997/node-jsonrpc';
import { MyTransportServer } from './my-transport'; // Your transport implementation

const server = new JSONRPCServer({
  transportServer: new MyTransportServer(),
});

// Register method handlers
server.registerMethod('subtract', async (params) => {
  return params.minuend - params.subtrahend;
});

server.registerMethod('sum', async (params) => {
  return params.reduce((a: number, b: number) => a + b, 0);
});

await server.listen();

// Send notification to all connected clients
server.broadcast('serverStatus', { status: 'ready' });

Examples

The examples/ directory contains complete, runnable examples demonstrating various features:

Client Examples

Server Examples

Testing Examples

Transport Abstraction

This package is transport-agnostic. You need to provide a Transport implementation for the client and a TransportServer implementation for the server.

See TRANSPORT.md for details on implementing custom transports.

Available Transports

  • node-ipc-jsonrpc - IPC transport (Unix sockets, Windows named pipes)
  • More coming soon...

Documentation

API Overview

JSONRPCClient

class JSONRPCClient extends EventEmitter {
  constructor(config: JSONRPCClientConfig);

  connect(): Promise<void>;
  disconnect(): Promise<void>;
  isConnected(): boolean;

  request<T>(method: string, params?: any, options?: RequestOptions): Promise<T>;
  notify(method: string, params?: any): void;
  batch(): BatchRequest;

  use(middleware: Middleware): void;

  // Events: 'connected', 'disconnected', 'notification', 'error'
}

JSONRPCServer

class JSONRPCServer extends EventEmitter {
  constructor(config: JSONRPCServerConfig);

  listen(): Promise<void>;
  close(): Promise<void>;

  registerMethod(name: string, handler: Handler): void;
  use(middleware: Middleware): void;

  notify(transport: Transport, method: string, params?: any): void;
  broadcast(method: string, params?: any): number;

  // Events: 'notification', 'error'
}

License

MIT © gnana997