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

mockapi-runner

v1.0.0

Published

Spin up a mock REST API server from a JSON schema file in seconds

Downloads

89

Readme

mock-api-cli

Spin up a mock REST API server from a JSON schema file in seconds. No dependencies. Pure Node.js.

npm version License: MIT

Features

  • Zero dependencies — uses only Node.js built-ins (http, fs, path, url)
  • Define any GET / POST / PUT / PATCH / DELETE routes in a single JSON file
  • Auto-generates a sample routes.json on first run
  • Path parameters (:id, :slug) matched automatically
  • Wildcard paths (/files/*)
  • CORS headers included by default
  • Simulated network delay (--delay)
  • Verbose request logging (--verbose)

Install

npm install -g mock-api-cli

Or use without installing:

npx mock-api-cli --port 3001

Quick Start

# Start on default port 3000 (auto-creates routes.json)
mock-api

# Start on custom port with custom config
mock-api --port 8080 --config my-api.json

# Add 200ms artificial latency
mock-api --port 3001 --delay 200

# Log every request
mock-api --verbose

Config Format (routes.json)

[
  {
    "method": "GET",
    "path": "/users",
    "status": 200,
    "response": [
      { "id": 1, "name": "Alice", "email": "[email protected]" },
      { "id": 2, "name": "Bob",   "email": "[email protected]" }
    ]
  },
  {
    "method": "GET",
    "path": "/users/:id",
    "status": 200,
    "response": { "id": 1, "name": "Alice", "email": "[email protected]" }
  },
  {
    "method": "POST",
    "path": "/users",
    "status": 201,
    "response": { "id": 3, "created": true }
  },
  {
    "method": "DELETE",
    "path": "/users/:id",
    "status": 200,
    "response": { "deleted": true }
  },
  {
    "method": "GET",
    "path": "/health",
    "status": 200,
    "response": { "status": "ok" }
  }
]

Each route object has:

| Field | Type | Description | |------------|-----------------|------------------------------------------| | method | string | HTTP method (GET, POST, PUT, PATCH, DELETE) | | path | string | URL path — supports :param and /* wildcards | | status | number | HTTP response status code (default: 200) | | response | object or array | JSON body to return |

CLI Options

--port,    -p  <number>   Port to listen on            (default: 3000)
--config,  -c  <file>     Path to routes JSON file     (default: routes.json)
--delay,   -d  <ms>       Artificial response delay
--verbose                 Log every incoming request
--version, -v             Show version
--help,    -h             Show help

Example Session

$ mock-api --port 3001
[mock-api] Server running at http://localhost:3001
[mock-api] Loaded 7 route(s):

  GET     /users         → 200
  GET     /users/:id     → 200
  POST    /users         → 201
  PUT     /users/:id     → 200
  DELETE  /users/:id     → 200
  GET     /products      → 200
  GET     /health        → 200

$ curl http://localhost:3001/users
[
  { "id": 1, "name": "Alice Johnson", ... },
  ...
]

$ curl http://localhost:3001/users/42
{ "id": 1, "name": "Alice Johnson", ... }

$ curl -X POST http://localhost:3001/users
{ "id": 4, "created": true }

$ curl http://localhost:3001/nonexistent
{ "error": "Not Found", "message": "No route matched: GET /nonexistent", ... }

Use Cases

  • Frontend development without a real backend
  • Testing API client code
  • CI/CD pipeline integration tests
  • Teaching REST API concepts
  • Prototyping new services

License

MIT