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

@adhd/apigen-plugin-health

v0.2.2

Published

**Mount plugin** — adds a `GET /_meta/health` endpoint to any apigen server. Reports runtime readiness for load balancers, orchestrators, and the apigen gateway (§13).

Readme

@adhd/apigen-plugin-health

Mount plugin — adds a GET /_meta/health endpoint to any apigen server. Reports runtime readiness for load balancers, orchestrators, and the apigen gateway (§13).

Part of apigen. Driven via @adhd/apigen-cli.


What it adds

When loaded via --use, the health plugin contributes a synthetic _meta/health operation that returns:

GET /_meta/health
→ {"status":"ok","host":"ts"}

The gateway (§13.1) routes a host's operations only after this endpoint reports ready. For an in-process runtime (non-gateway), it always reports ok — if the handler can respond, the runtime is alive.


CLI usage

# Fastify with health check
npx @adhd/apigen-cli run --source api.ts --type api-fastify --opt port=3000 --use health

# MCP with health check (SSE transport)
npx @adhd/apigen-cli run --source api.ts --type mcp --opt transport=sse --opt port=3000 --use health

# With custom metadata in the response
npx @adhd/apigen-cli run --source api.ts --type api-fastify --use health \
  --opt 'useOptions={"health":{"meta":{"version":"1.0","region":"us-east"}}}'

After startup:

curl http://localhost:3000/_meta/health
# → {"status":"ok","host":"ts","meta":{"version":"1.0","region":"us-east"}}

Programmatic usage

import { extract, composeSchemas } from '@adhd/apigen-core-client';
import { apiFastifyPlugin } from '@adhd/apigen-plugin-api-fastify';
import { healthPlugin } from '@adhd/apigen-plugin-health';

const ops = await extract({ sourceFile: './api.ts', namespace: 'api' });
const schemas = composeSchemas(
  {
    metadata: { namespace: 'api', phase: '' },
    schemas: Object.fromEntries(
      ops.filter(o => o.kind === 'action').map(op => [
        op.path[op.path.length - 1].raw,
        { input: op.input, output: op.output, hasCtx: op.hasCtx, 'x-apigen-safe': op.safe },
      ])
    ),
  },
  []
);
const mod = await import('./api.ts');

const abort = new AbortController();
process.on('SIGINT', () => abort.abort());

await apiFastifyPlugin.run({
  packages: [{ id: 'api', schemas, importPath: './api.ts', fns: mod, createClient: async () => ({}) }],
  outputDir: '',
  options: {
    port: 3000,
    host: '0.0.0.0',
    usePlugins: [
      healthPlugin,   // ← mounts GET /_meta/health
    ],
    // With custom metadata:
    // useOptions: { health: { meta: { version: '1.0', region: 'us-east' } } },
  },
  signal: abort.signal,
  operations: ops,
});

Options

import { type HealthOptions } from '@adhd/apigen-plugin-health';

| Option | Type | Default | Description | |--------|------|---------|-------------| | meta | Record<string, string \| number \| boolean \| null> | undefined | Extra metadata included in every health response payload |


Response shape

interface HealthResponse {
  status: 'ok';
  host: string;                          // language runtime tag (e.g. 'ts')
  meta?: Record<string, string | number | boolean | null>;
}

Exports

| Export | Kind | |--------|------| | healthPlugin | v2 Plugin<HealthOptions> — mount capability only | | HealthOptions | TypeScript interface | | HealthResponse | TypeScript interface |

import { healthPlugin, type HealthOptions, type HealthResponse } from '@adhd/apigen-plugin-health';