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

@plonklabs/flatbed-client

v0.0.1

Published

Runtime and generator for FlatBuffer clients of flatbed services.

Readme

@plonklabs/flatbed-client

The runtime and code generator for TypeScript FlatBuffer clients of flatbed services.

flatbed-client generate reads a running service's /openapi.json (operations) and /schema.bfbs (the FlatBuffer wire schema) and emits a typed client — pure TypeScript, no Rust toolchain and no flatc:

npm i -D @plonklabs/flatbed-client
npx flatbed-client generate --server http://localhost:8080 --out src/api

It writes five files into --out:

  • types.ts — an interface per table and a numeric enum (true wire values).
  • codec.tsencode…Root for each request body and decode…Root for each response body, over the flatbuffers runtime, byte-identical to flatbed's Rust codec. Only the directions a client uses are emitted.
  • json-codec.tsencode…Json for each request body and decode…Json for each response body, matching flatbed's JSON wire shape (enums as variant names, numbers for scalars).
  • client.ts — a createFlatbedClient(config) factory with one method per route.
  • index.ts — a barrel re-exporting the folder.

Pass --openapi <file> --schema <file> instead of --server to generate from saved files offline.

Using the client

import { createFlatbedClient, Priority } from "./api";

const api = createFlatbedClient({ baseUrl: "http://localhost:8080" });

// Each method takes a single object; `body` is the operation's Request Table,
// `pathParams` its path parameters — only the keys the operation actually has.
const echo = await api.postEcho({ body: { message: "hi", times: 3, priority: Priority.Low } });
const user = await api.getUsersById({ pathParams: { id: "42" } });
const saved = await api.putUsersById({ body: { name: "x" }, pathParams: { id: "42" } });

ClientConfig also takes headers added to every request:

const api = createFlatbedClient({
  baseUrl: "http://svc:8080",
  headers: { authorization: `Bearer ${token}` },
});

Choosing the wire format

Every call sends FlatBuffer by default. Pass { as: "json" } as a second argument to make that call over JSON instead — the option is generated only for operations the spec advertises for both formats:

// FlatBuffer (default)
const echo = await api.postEcho({ body: { message: "hi", times: 3, priority: Priority.Low } });

// same operation, JSON — chosen per call
const echoJson = await api.postEcho({ body: { message: "hi", times: 3, priority: Priority.Low } }, { as: "json" });

FlatBuffer is compact and covers the full wire range; JSON is human-readable. On the JSON path, 64-bit integers (bigint) are limited to the safe-integer range — the server encodes them as JSON numbers, so a value above 2^53 loses precision. Use the FlatBuffer path when full 64-bit range matters.

Transport — open for extension, closed for modification

The client depends on a Transport interface, never on fetch directly. The default is fetch; provide your own to use axios, add retries, or interceptors — without editing any generated code:

import { createFlatbedClient, type Transport } from "@plonklabs/flatbed-client";

const axiosTransport: Transport = {
  send: ({ method, url, headers, body }) =>
    axios
      .request({ method, url, headers, data: body, responseType: "arraybuffer", validateStatus: () => true })
      .then((r) => ({ status: r.status, ok: r.status >= 200 && r.status < 300, body: new Uint8Array(r.data) })),
};

const api = createFlatbedClient({ baseUrl: "http://svc:8080", transport: axiosTransport });

A non-2xx response rejects with FlatbedError carrying the status.