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

ohdear-npm-audit

v1.5.0

Published

Oh Dear Application Health check for npm audit critical vulnerabilities

Readme

ohdear-npm-audit

Oh Dear Application Health check for critical npm vulnerabilities.

Designed for serverless platforms (Vercel, Netlify...) where you can't run npm audit at runtime. Instead, a dependency manifest is generated at build time and checked against the npm advisory API on each health check request.

Disclaimer: This package is not affiliated with or endorsed by Oh Dear. It is a community-built integration that implements the Oh Dear application health check protocol.

Install

npm install ohdear-npm-audit

Setup

1. Generate the dependency manifest at build time

Option A — CLI (works with any framework)

"build": "ohdear-deps-manifest --output src/app/api/health/deps-manifest.json && next build"

Option B — Next.js config wrapper

// next.config.mjs
import { withOhDearHealth } from "ohdear-npm-audit/next";

export default withOhDearHealth({
  // your Next.js config
});

The wrapper generates the manifest automatically when the config is evaluated (before the build starts). It also checks for critical vulnerabilities at build time and logs enriched results including dependency chains and vulnerable version ranges:

ohdear-npm-audit: 1 critical vulnerabilities:
  - [email protected] (via axios → form-data): unsafe random function
    vulnerable: <1.0.1 — https://github.com/advisories/GHSA-xxx
withOhDearHealth(nextConfig, {
  output: "src/app/api/health/deps-manifest.json", // default
  checkOnBuild: true, // default — set to false to skip the build-time vulnerability check
});

2. Create the health check route

// src/app/api/health/route.ts (Next.js App Router)
import { createHealthHandler } from "ohdear-npm-audit";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore — generated at build time by ohdear-npm-audit
import manifest from "./deps-manifest.json" with { type: "json" };

export const GET = createHealthHandler(manifest);

Note: The @ts-ignore is needed because deps-manifest.json does not exist until the first build. Do not use @ts-expect-error — it will fail the build since the file exists at that point.

3. Set the environment variable

OHDEAR_HEALTH_SECRET=your-secret-here

This must match the secret configured in Oh Dear for your application health check.

4. Add to .gitignore

**/deps-manifest.json

How it works

  1. Build time — The CLI or Next.js wrapper runs pnpm list / npm ls to extract all production dependencies (including transitive) and writes them to a JSON manifest that includes a reverse dependency map for tracing dependency chains. When using the Next.js wrapper, a build-time vulnerability check is performed and results are logged with the full dependency chain (e.g. axios → form-data) and vulnerable version ranges
  2. Runtime — On each GET request, the handler verifies the Oh Dear secret header, POSTs the manifest to the npm bulk advisory API, filters for critical severity, and returns the result in the Oh Dear health check format. Each vulnerability includes installed versions, vulnerable version range, and the dependency chain

Response format

{
  "finishedAt": 1708300000,
  "checkResults": [
    {
      "name": "npm_vulnerabilities",
      "label": "NPM Critical Vulnerabilities",
      "status": "ok",
      "notificationMessage": "No critical npm vulnerabilities found.",
      "shortSummary": "0 critical",
      "meta": {}
    }
  ]
}

When vulnerabilities are found, meta.vulnerabilities contains an array of:

{
  "package": "form-data",
  "installedVersions": ["1.0.0"],
  "title": "form-data uses unsafe random function",
  "url": "https://github.com/advisories/GHSA-xxx",
  "vulnerableVersions": "<1.0.1",
  "dependencyChain": ["axios", "form-data"]
}

status is "ok" when there are no critical vulnerabilities, "warning" when the npm advisory API is unreachable, "failed" otherwise.

API

createHealthHandler(manifest, options?)

Returns a (request: Request) => Promise<Response> handler compatible with any framework that uses the Web Request/Response API (Next.js, Hono, SvelteKit...).

| Option | Default | Description | |--------|---------|-------------| | secretEnvVar | "OHDEAR_HEALTH_SECRET" | Environment variable name for the secret | | secretHeader | "oh-dear-health-check-secret" | Request header name for the secret |

withOhDearHealth(nextConfig, options?)

Next.js config wrapper that generates the manifest before the build.

| Option | Default | Description | |--------|---------|-------------| | output | "src/app/api/health/deps-manifest.json" | Output path for the manifest | | checkOnBuild | true | Check for critical vulnerabilities at build time |

CLI ohdear-deps-manifest

ohdear-deps-manifest --output path/to/deps-manifest.json

Defaults to deps-manifest.json in the current directory. Detects the package manager (pnpm or npm) from the lockfile.

Note: Yarn is not supported. Use pnpm or npm.

Contributing

Architecture

src/
├── types.ts      # Shared types (DepsManifest, Vulnerability, HealthCheckResponse)
├── generate.ts   # Manifest + reverse dep map generation (build-time, execSync)
├── handler.ts    # createHealthHandler factory — main export "."
├── next.ts       # withOhDearHealth wrapper — export "./next"
└── bin.ts        # CLI entry point — bin "ohdear-deps-manifest"

Package manager detection

The manifest generator detects the package manager from the lockfile in the project root:

  • pnpm-lock.yamlpnpm list --json --prod --depth Infinity
  • Otherwise → npm ls --json --omit=dev --all
  • yarn.lock → error (not supported)

Building

pnpm install
pnpm build

CJS output. TypeScript compiled with tsc, output in dist/. Compatible with both require() and import.

Credits

Made by Breaking Web.

License

MIT