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

@jsontpc/express

v0.1.0

Published

Express middleware adapter for @jsontpc/core

Readme

@jsontpc/express

Express middleware adapter for @jsontpc/core.


Installation

pnpm add @jsontpc/express @jsontpc/core
pnpm add express          # peer dependency

jsonRpcExpress(server, options?)

Returns an Express RequestHandler that dispatches JSON-RPC requests to the given JsonRpcServer.

Signature

function jsonRpcExpress(
  server: JsonRpcServer,
  options?: JsonRpcExpressOptions,
): RequestHandler

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | maxMessageSize | number | 1_048_576 (1 MiB) | Max raw body bytes. Only enforced when express.json() is not used upstream. |

Usage — without express.json()

The middleware reads the raw request body directly and enforces maxMessageSize.

import express from 'express';
import { JsonRpcServer } from '@jsontpc/core';
import { jsonRpcExpress } from '@jsontpc/express';

const server = new JsonRpcServer(router);
const app = express();

app.post('/rpc', jsonRpcExpress(server));
app.listen(3000);

Usage — with express.json() upstream

When express.json() is mounted first, the adapter detects the pre-parsed req.body and re-serializes it. The maxMessageSize option has no effect in this mode (Express's own limit option applies instead).

const app = express();
app.use(express.json());                  // Express enforces body limit here
app.post('/rpc', jsonRpcExpress(server));
app.listen(3000);

HTTP response codes

| Scenario | Status | |----------|--------| | Normal response | 200 application/json | | Notification / all-notification batch | 204 No Content | | Body exceeds maxMessageSize (raw mode) | 413 |

HTTP method and path filtering is handled by Express routing (app.post). The middleware itself does not restrict the HTTP method.


Client

Use HttpClientTransport from @jsontpc/http to call the Express server:

import { createClient } from '@jsontpc/core';
import { HttpClientTransport } from '@jsontpc/http';

const client = createClient<typeof router>(
  new HttpClientTransport('http://localhost:3000/rpc')
);

const result = await client.add({ a: 1, b: 2 }); // 3

How it works

jsonRpcExpress is implemented with bindAdapter from @jsontpc/core. It never reimplements the JSON-RPC dispatch loop — parse → handle/handleBatch → serialize is always delegated to core.


See docs/ARCHITECTURE.md §7.1 for the full design.