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

@mr-aftab-ahmad-khan/typepress

v0.1.3

Published

Type-safe API framework for Express. Define routes once, get runtime validation, OpenAPI, TypeScript types, and a generated fetch client for free.

Readme

typepress

Type-safe API framework for Express. Define a route once and get:

  • Runtime validation of body, query, params, and response
  • Static TypeScript types for the handler context and return value
  • An OpenAPI 3.1 document (toOpenApi)
  • A typed fetch client you can ship to the frontend (generateTypescriptClient)

No code generation step required at runtime, no zod dependency — typepress includes a tiny t builder with the operators you actually need (string, number, boolean, enums, literal, array, object, optional, union).

Install

npm install @mr-aftab-ahmad-khan/typepress

Define routes

import express from "express";
import { createTypepress, t } from "@mr-aftab-ahmad-khan/typepress";

const api = createTypepress();

api.get<unknown, { limit: number }>(
  "/users",
  ({ query }) => db.users.list({ limit: query.limit }),
  {
    query: t.object({ limit: t.number({ integer: true, min: 1, max: 100 }) }),
    response: t.array(
      t.object({ id: t.string(), name: t.string(), email: t.string({ format: "email" }) }),
    ),
  },
);

api.post<{ name: string; email: string }>(
  "/users",
  ({ body }) => db.users.create(body),
  {
    body: t.object({
      name: t.string({ min: 1 }),
      email: t.string({ format: "email" }),
    }),
    response: t.object({ id: t.string(), name: t.string(), email: t.string() }),
  },
);

const app = express();
app.use(express.json());
api.attach(app);
app.listen(3000);

When validation fails:

{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "body.email: invalid email", "field": "body" } }

When the handler returns an invalid response (because you mis-implemented a field), typepress returns a 500 with RESPONSE_VALIDATION — so contract drift is caught in tests instead of the wild.

OpenAPI

import { toOpenApi } from "@mr-aftab-ahmad-khan/typepress";

app.get("/openapi.json", (_req, res) => res.json(toOpenApi(api, {
  title: "My API",
  version: "1.0.0",
  servers: [{ url: "https://api.example.com" }],
})));

Typed client for the frontend

import { generateTypescriptClient } from "@mr-aftab-ahmad-khan/typepress";
import { writeFileSync } from "node:fs";

writeFileSync(
  "./src/generated-client.ts",
  generateTypescriptClient(api, { className: "ApiClient" }),
);

Then in your React/Vue/etc. app:

import { ApiClient } from "./generated-client";

const api = new ApiClient({ baseUrl: "https://api.example.com" });
const users = await api.getUsers({ query: { limit: 20 } });
//    ^? Array<{ id: string; name: string; email: string }>

Errors thrown by the client have a code, status, and message mirroring the server envelope.

API

| Symbol | What | | --- | --- | | createTypepress() | New router | | api.get/post/put/patch/delete(path, handler, schemas?) | Register a route | | api.attach(expressApp) | Wire all routes onto an Express app/Router | | api.list() | Inspect registered routes (used by OpenAPI/client generators) | | toOpenApi(api, options?) | Generate OpenAPI 3.1 document | | generateTypescriptClient(api, options?) | Generate a typed fetch client | | t.string/number/boolean/literal/enums/array/object/optional/union/unknown | Schema builder |

License

MIT