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.9.2

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

HTTP wire for Nwire — Koa underneath, Zod schemas, OpenAPI 3.1 from the live wiring, Scalar docs.

httpInterface() is a small chainable builder that ties Zod-validated routes to handler functions. Works three ways: standalone (bring your own Container), with a Nwire app (endpoint().serve(app).serve(api)), or as interop (api.compile() mounts on Express / Fastify / Koa / Nest via the thin @nwire/http-* adapter packages).

pnpm add @nwire/http @nwire/endpoint zod

Quick example — standalone

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();

http://localhost:3000/openapi.json returns the live spec; /docs serves Scalar UI from CDN; /healthz + /readyz come from the endpoint layer.

Quick example — with a Nwire app

import { createApp } from "@nwire/forge";
import { httpInterface, post } from "@nwire/http";
import { endpoint } from "@nwire/endpoint";

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 ctx.resolve() automatically; no .provide() needed when an app is served alongside.

Quick example — Express interop

import express from "express";
import { toExpress } from "@nwire/http-express";

const expressApp = express();
expressApp.use("/nwire", toExpress(api));
expressApp.listen(3000);

Surface

| Export | Role | | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | httpInterface(options?) | Builder. .use(mw) / .provide(container) / .wire(binding, handler) / .compile() / .toKoa(). | | get / post / put / patch / del | Verb-builder route factories. Each takes RouteSchemas (params / query / body) + OpenAPI metadata. | | defineCheck(name, fn) | Readiness probe (re-exported from @nwire/endpoint). | | buildOpenApiDocument(api, info) | OpenAPI 3.1 emitter; auto-mounted by the builder when openapi.info is set. | | scalarHtml(specUrl) | Scalar docs HTML for the /docs route. | | attachLifecycle / HealthCheck / HealthConfig / ShutdownConfig | Re-exports from @nwire/endpoint for one-package consumers. |

Response shapes

Handlers return either a plain value (200 OK, JSON-serialized) or a tagged response:

return { id: "1", name: "Alice" }; // 200 OK
return { $status: 201, body: { id: "1" } }; // custom status
return { $status: 204 }; // no content
throw new NotFoundError("user", input.id); // serialized as JSON error

Per-route middleware

Middleware lives on the route binding so each route gets its own http.request:<METHOD> <path> hook for taps + OTel spans:

.wire(
  post("/orders", {
    body: OrderInput,
    middleware: [authenticate, requireRole("operator")],
  }),
  createOrderHandler,
)

Related

  • @nwire/endpoint — wraps the interface in a Node process with probes + graceful shutdown.
  • @nwire/http-expresstoExpress(api) / fromExpress(mw) interop.
  • @nwire/forge — supplies defineAction / defineResource for handlers that dispatch.
  • @nwire/hooks — the dispatch substrate; global http.request + per-route hooks live here.

Status

v0.x — builder verbs (.use / .provide / .wire / .compile / .toKoa) and route-binding shape are locked. Per-route OpenAPI metadata is additive.