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

@mockingbirdjs/core

v0.1.0

Published

Framework-agnostic fixture store, request matching, sanitization, and middleware powering Mockingbird.

Readme

@mockingbirdjs/core

Framework-agnostic engine powering Mockingbird — fixture store, request matching, sanitization pipeline, and Node.js middleware.

Used internally by @mockingbirdjs/vite and @mockingbirdjs/next. Install this directly if you want to build a Mockingbird adapter for another framework (Express, Fastify, Nuxt, Remix, etc.).

Install

npm i @mockingbirdjs/core

Quick start

import { resolveCoreConfig, createRuntime } from "@mockingbirdjs/core";
import type { IncomingMessage, ServerResponse } from "node:http";

const config = resolveCoreConfig({
  dir: "./mockingbird",   // fixture directory
  mode: "hybrid",         // 'live' | 'mock' | 'hybrid'
});

const runtime = createRuntime(config);
await runtime.init();

// Drop runtime.middleware into any Node.js HTTP server
app.use(runtime.middleware);

resolveCoreConfig(options)

Merges your options with defaults and returns a fully-resolved CoreConfig.

resolveCoreConfig({
  // Fixture directory (absolute or relative to cwd). Default: 'mockingbird'
  dir: "./mockingbird",

  // Starting mode. Default: 'hybrid'
  mode: "hybrid",

  // Request matching
  match: {
    body: true,             // match on request body hash
    headers: [],            // additional headers to match on
    inferPathParams: true,  // auto-detect [id]-style path segments
    query: { ignore: [] },  // 'all' | 'none' | { only?, ignore? }
  },

  // Recording
  record: {
    maxBodyBytes: 5_000_000,
    maxVariantsPerEndpoint: 10,
    onDuplicate: "update",    // 'update' | 'keep' | 'variants'
    latency: true,
    wildcardFallback: true,   // write a wildcard fallback for parameterised routes
  },

  // Replay
  replay: {
    latency: "none",  // 'none' | 'recorded' | ms | { min, max }
  },

  // Per-route overrides — first match wins
  routes: [
    { pattern: "GET /api/flags", mode: "live" },
    { pattern: "/api/analytics/**", ignore: true },
  ],

  // Sanitization (applied before anything hits disk)
  sanitize: {
    disable: false,
    allowRequestHeaders: ["content-type", "accept"],
    headers: ["set-cookie", "authorization", "x-api-key"],
    bodyPaths: ["**.password", "**.token", "**.apiKey"],
    queryParams: ["token", "key", "access_token"],
    placeholder: "«redacted»",
  },

  // Last-chance hook before a recording hits disk. Return null to drop.
  onRecord: (exchange) => exchange,
})

createRuntime(config)

Creates a Runtime instance that holds the fixture store, middleware, and event bus.

interface Runtime {
  config: CoreConfig;
  counters: SessionCounters;      // hits, misses, recorded this session
  init(): Promise<void>;          // scaffold dirs, load state
  middleware: NodeMiddleware;      // (req, res, next) => void
  mode(): Mode;                   // current mode
  setMode(mode: Mode): Promise<void>;
  store: FsStore;                 // direct fixture store access
  onEvent(listener): () => void;  // subscribe to runtime events
  handleWatcherEvent(            // feed file-watcher events
    event: "add" | "change" | "unlink",
    file: string
  ): boolean;
}

FsStore

Reads and writes fixture files under config.dir/fixtures/.

const store = runtime.store;

// Load all fixtures
const fixtures = await store.load();

// Find best match for a request
const match = await store.resolve(normalizedRequest, config);

// Save a fixture
await store.save(fixtureFile, config);

State management

import { readState, writeState, resolveMode } from "@mockingbirdjs/core";

const state = await readState(config.dir);          // reads .state.json
const mode = resolveMode(state, config);            // applies env var override
await writeState(config.dir, { mode: "mock" });

Key types

type Mode = "live" | "mock" | "hybrid";

interface RouteOverride {
  pattern: string;          // 'GET /api/users/**' or glob
  mode?: Mode;
  ignore?: boolean;
  match?: Partial<MatchConfig>;
  record?: Partial<RecordConfig>;
  replay?: Partial<ReplayConfig>;
}

interface RecordedExchange {
  meta: { recordedAt: string; origin: string };
  request: { method: string; path: string; url: string; params; query; headers; body? };
  response: { status: number; headers; body: unknown; latencyMs: number };
}

type OnRecordHook = (exchange: RecordedExchange) => RecordedExchange | null | undefined;

See the full type definitions for the complete surface.