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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mocks-rs/mocks

v1.0.9

Published

Mock REST APIs from JSON with zero coding within seconds.

Readme

mocks

Mock REST APIs from JSON with zero coding within seconds.

npm version codecov Ask DeepWiki License

Complete Documentation - For detailed usage, advanced features, and examples.

Install

npm install -g @mocks-rs/mocks

Or use without installing:

npx @mocks-rs/mocks --help

Quick Start

1. Initialize a storage file

Create a JSON file using the init command:

npx @mocks-rs/mocks init storage.json

Or if installed globally:

mocks init storage.json

This creates a storage.json file with sample data. Use the --empty option to create an empty structure:

npx @mocks-rs/mocks init --empty storage.json

Or if installed globally:

mocks init --empty storage.json

2. Run a REST API server

Start the mock server using your JSON file:

npx @mocks-rs/mocks run storage.json

Or if installed globally:

mocks run storage.json

Example JSON structure:

{
  "posts": [
    { "id": "01J7BAKH37HPG116ZRRFKHBDGB", "title": "first post", "views": 100 },
    { "id": "01J7BAKH37GE8B688PT4RC7TP4", "title": "second post", "views": 10 }
  ],
  "profile": { "id": "01J7BAQE1GMD78FN3J0FJCNS8T", "name": "mocks" }
}

3. Use your mock API

This automatically creates REST endpoints:

# List all posts
curl http://localhost:3000/posts

# Get a specific post
curl http://localhost:3000/posts/01J7BAKH37HPG116ZRRFKHBDGB

# Get profile (singleton resource)
curl http://localhost:3000/profile

# Create a new post
curl -X POST http://localhost:3000/posts \
  -H "Content-Type: application/json" \
  -d '{"title": "new post", "views": 0}'

# Health check
curl http://localhost:3000/_hc

Available Endpoints

For each resource in your JSON file, mocks automatically creates:

  • GET /{resource} - List all items
  • GET /{resource}/{id} - Get specific item
  • POST /{resource} - Create new item
  • PUT /{resource}/{id} - Replace entire item
  • PATCH /{resource}/{id} - Partial update
  • DELETE /{resource}/{id} - Delete item
  • GET /_hc - Health check (returns 204)

Documentation

For detailed information about advanced configuration, query parameters, filtering, and more features, visit the complete documentation.

Contributing

This project is open source. Visit the GitHub repository to contribute or report issues.

License

This project is licensed under the MIT license.