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

@ibabkin/openapi-express-server

v3.2.0

Published

Express.js server implementation for OpenAPI-generated interfaces

Readme

@ibabkin/openapi-express-server

Express.js building blocks for wiring routes from an OpenAPI spec to use cases resolved from a ts-ioc-container scope. Pairs with @ibabkin/openapi-to-server (one <Op>HttpRoute interface per operation) and @ibabkin/openapi-to-zod (Zod payload validators).

Exports

  • extractRoutes(spec) — flattens an OpenAPIV3.Document into RouteMetadata[] (path, method, operationId, tags); operationId is the DI key of the operation's use case, tags are the operation's tags verbatim
  • convertOpenAPIPathToExpress(path) — /users/{id} → /users/:id
  • buildPayload(req) — picks params, query, body, headers off an Express request
  • containerMiddleware(appContainer, tags?) — creates a request-scoped child container tagged ['request', ...tags], attaches it to req.container, and disposes it when the response finishes. Mount it per route with route.tags so registrations bound to a tag (scope((s) => s.hasTag('admins'))) apply to exactly the operations carrying it
  • getContainerOrFail(req) — reads req.container or throws

Usage

Register one use case per operation in an application container, keyed by its operationId, then register one Express route per operation. A reference RouteBuilder that does exactly this lives in __tests__/RouteBuilder.ts:

import 'reflect-metadata';
import express from 'express';
import { Container, Registration } from 'ts-ioc-container';
import { PAYLOADS } from './generated-validators';
import { RouteBuilder } from './RouteBuilder';

const container = new Container({ tags: ['application'] });
container.addRegistration(Registration.fromClass(GetUsers).bindToKey('getUsers'));
container.addRegistration(Registration.fromClass(CreateUser).bindToKey('createUser'));

const app = express();
app.use(express.json());

container.resolve(RouteBuilder, { args: [spec, PAYLOADS] }).applyTo(app);

app.use((error, req, res, next) => {
  res.status(error instanceof ZodError ? 400 : 500).json({ error: error.message });
});

Each route mounts containerMiddleware(container, route.tags), so every request gets a scope tagged with request and the operation's tags. The handler resolves the use case from that scope under the operationId, validates req with the Zod schema for the same operationId, calls useCase.handle(payload, scope), and writes { status, headers, body } to the response.

For AI agents

The package ships AGENTS.md, a compact guide for coding agents: the one-route-per-operation wiring recipe (exercised by __tests__/agentGuides.spec.ts), the request-scope model and the pitfalls. After installation it is at node_modules/@ibabkin/openapi-express-server/AGENTS.md. Point your agent at it from your own AGENTS.md or CLAUDE.md.

Development

pnpm build
pnpm test

__tests__/integration/generated.spec.ts generates types and validators from __tests__/integration/api.yaml at test time and runs an end-to-end server against them.

License

ISC