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

@chengyixu/mockapi

v1.0.0

Published

Instantly spin up a mock REST API from a JSON file. Zero-config CRUD endpoints, hot reload, request recording, and OpenAPI spec generation.

Readme

@chengyixu/mockapi

Instantly spin up a mock REST API from a JSON file. Zero-config CRUD endpoints with hot reload, request recording, and OpenAPI spec generation.

Install

npm install -g @chengyixu/mockapi

Quick Start

Create a db.json file:

{
  "users": [
    { "id": 1, "name": "Alice", "email": "[email protected]" },
    { "id": 2, "name": "Bob", "email": "[email protected]" }
  ],
  "posts": [
    { "id": 1, "title": "Hello World", "userId": 1 }
  ]
}

Start the server:

mockapi serve db.json

You now have a full REST API:

GET    /users        # List all users
GET    /users/1      # Get user by ID
POST   /users        # Create a new user
PUT    /users/1      # Update a user
DELETE /users/1      # Delete a user

Features

  • Auto CRUD - Endpoints auto-generated from JSON keys
  • Hot Reload - Server reloads when the JSON file changes
  • Query Filtering - GET /users?name=Alice
  • Sorting - GET /users?_sort=name&_order=desc
  • Pagination - GET /users?_page=1&_limit=10
  • Custom Routes - Define custom endpoints via config
  • Artificial Latency - Simulate slow APIs with --delay
  • CORS Enabled - Works with any frontend out of the box
  • Colored Logging - Method-colored request logs
  • Record Mode - Proxy a real API and save responses
  • OpenAPI Spec - Auto-generate OpenAPI 3.0 from your data
  • Zero External Deps - Server uses native Node.js http module

Commands

mockapi serve <file>

Start a mock REST API server.

mockapi serve db.json
mockapi serve db.json --port 8080
mockapi serve db.json --delay 500        # 500ms latency
mockapi serve db.json --routes routes.json
mockapi serve db.json --no-watch         # Disable hot reload

Options:

  • -p, --port <number> - Port (default: 3000)
  • -H, --host <string> - Host (default: localhost)
  • -d, --delay <ms> - Artificial latency in ms (default: 0)
  • -r, --routes <file> - Custom routes JSON file
  • --no-watch - Disable hot reload

mockapi record <url>

Proxy requests to a real API and record responses.

mockapi record https://jsonplaceholder.typicode.com
mockapi record https://api.example.com -o api-data.json -p 8080

Options:

  • -p, --port <number> - Local proxy port (default: 3000)
  • -H, --host <string> - Host (default: localhost)
  • -o, --output <file> - Output file (default: recorded.json)

mockapi openapi <file>

Generate an OpenAPI 3.0 specification from your data file.

mockapi openapi db.json                  # Print to stdout
mockapi openapi db.json -o spec.json     # Write to file

Custom Routes

Create a routes.json:

[
  {
    "method": "GET",
    "path": "/health",
    "status": 200,
    "body": { "status": "ok" }
  },
  {
    "method": "POST",
    "path": "/login",
    "status": 200,
    "body": { "token": "mock-jwt-token" }
  }
]
mockapi serve db.json --routes routes.json

License

MIT