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

@nwire/http

v0.7.1

Published

Nwire — HTTP transport. httpInterface() builds a Koa app via the 6-verb InterfaceBuilder (.use / .wire / .from / .mount / .run / .boot), adds default middleware (cors, bodyparser, error envelope, healthz), seeds envelope from headers, graceful shutdown.

Readme

@nwire/http

Typed HTTP transport for Nwire — Koa under the hood, Zod schemas, OpenAPI 3.1, Scalar docs, graceful shutdown.

What it is

A small chainable builder, httpInterface(), that ties Zod-validated routes to handler functions. Works three ways:

  1. Standalone — bring your own Container via .provide(container), mount on @nwire/endpoint, done. No forge, no app.
  2. With a Nwire appendpoint().serve(app).serve(api) and the app's container fulfils handler ctx automatically.
  3. Interopapi.compile() returns a (req, res) => void so the same interface mounts inside an existing Express, Fastify, Koa, or Nest host via the thin adapter packages (@nwire/http-express, …).

Every route's input schema produces both runtime validation and an OpenAPI 3.1 operation; the spec is generated from the live wiring, not codegen.

Install

pnpm add @nwire/http @nwire/endpoint zod

Quick start

import { httpInterface, get, post } from "@nwire/http";
import { endpoint } from "@nwire/endpoint";
import { z } from "zod";

const api = httpInterface({ prefix: "/api/v1" })
  .wire(get("/users/:id", { params: z.object({ id: z.string() }) }), async ({ input }) => ({
    id: input.id,
    name: "Alice",
  }))
  .wire(post("/users", { body: z.object({ name: z.string() }) }), async ({ input }) => ({
    $status: 201,
    body: { id: "1", name: input.name },
  }));

await endpoint("api", { port: 3000 }).serve(api).run();

Hit http://localhost:3000/openapi.json for the spec, /docs for the Scalar UI, /healthz and /readyz for the liveness probes.

With a Nwire app

import { createApp } from "@nwire/forge";
import { httpInterface } from "@nwire/http";
import { endpoint } from "@nwire/endpoint";
import { ordersModule } from "./orders";

const app = createApp({ modules: [ordersModule] });
const api = httpInterface({ prefix: "/api/v1" }).wire(
  post("/orders", { body: OrderInput }),
  async ({ input, dispatch }) => dispatch("orders.create", input),
);

await endpoint("api", { port: 3000 }).serve(app).serve(api).run();

The app's Container fulfils handler ctx.resolve() calls automatically; no .provide(container) needed when you serve an app.

API surface

  • httpInterface(options?) — the builder. Chainable: .use(mw) / .provide(container) / .wire(binding, handler) / .compile() / .toKoa().
  • get / post / put / patch / del — verb-builder route factories. Each accepts an optional RouteSchemas (params, query, body) plus OpenAPI metadata.
  • defineCheck(name, fn) — health/readiness check, plumbed by endpoint() to /healthz and /readyz.
  • buildOpenApiDocument(api, info) + scalarHtml(specUrl) — OpenAPI generation + docs HTML. Mounted automatically by the builder when openapi.info is configured.

Response shapes

Handlers return either:

// plain value → 200 OK, JSON-serialized
return { id: "1", name: "Alice" };

// tagged response → custom status + body
return { $status: 201, body: { id: "1" } };
return { $status: 204 };
return { $status: 404, body: { error: "not_found" } };

// thrown error → middleware envelopes as JSON
throw new NotFoundError("user", input.id);