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

mockforge-gateway

v0.1.2

Published

MockForge: The Ultimate Multi-Tenant Mock API Gateway

Readme

MockForge ⚡


🚀 The Pain Point

Modern microservice or multi-tenant SaaS environments are painful to mock locally. Setting up 15-20 backend services for integration tests or frontend development is slow and hogs system resources. Postman's cloud mock servers are sluggish and require paid plans for high volume, while other mocking gateways consume hundreds of megabytes of RAM.

MockForge solves this with a statically compiled Rust binary. It routes traffic for multiple tenants (services) using a single YAML configuration file, executes complex matching conditions, and manages in-memory CRUD state—all consuming less than 10 MB of RAM with sub-millisecond response times.


✨ Features

  • 🌐 Multi-Tenancy: Route mock API requests by Hostname (e.g. payment.local) or Path Prefix (e.g. /auth, /payment).
  • 💾 In-Memory Stateful CRUD: Bind mock endpoints to a dynamic state store. POST, PUT, PATCH, and DELETE requests directly update state in RAM, allowing subsequent GET requests to return the updated database state.
  • ⚙️ Rules Engine: Serve dynamic responses using simple conditional expressions (e.g. params.id == '404' or headers.x-api-key != 'secret').
  • 🔄 Hot Reloading: Instantly watches your config file. Changing your mock configurations updates the server routes in real-time without restarts.
  • 🏎️ Ultra Lightweight: Zero-dependency binary compiled in Rust. No Node.js runtime, no Docker, no external database required.

📦 Installation & Usage

1. Run Instantly (via npx)

No setup required. The wrapper CLI will detect your OS and download the optimized binary automatically:

npx mockforge-gateway --config mockforge.yaml --port 8080

2. Global Install

npm install -g mockforge-gateway
mockforge --config mockforge.yaml

3. Build From Source (Rust Cargo)

cargo install --git https://github.com/anilcan-kara/mockforge
mockforge --config mockforge.yaml

4. Direct Binary Download

You can download the precompiled static binary for your platform directly from the GitHub Release assets:


🛠️ Configuration Guide (mockforge.yaml)

Define all your mock microservices in a single, simple configuration file:

tenants:
  - name: auth-service
    prefix: /auth
    routes:
      # GET collection - binds to state store "users"
      - path: /users
        method: GET
        state: users
        default:
          status: 200
          body:
            - id: "1"
              name: "Anilcan Kara"
              role: "admin"
            - id: "2"
              name: "Nozich Bot"
              role: "assistant"

      # GET single item - matches id param
      - path: /users/:id
        method: GET
        state: users
        rules:
          - if: "params.id == '404'"
            status: 404
            body: { "error": "User not found" }
        default:
          status: 404
          body: { "error": "User not found in state store" }

      # POST item - inserts JSON payload into "users" list
      - path: /users
        method: POST
        state: users

      # PUT item - updates the object by ID
      - path: /users/:id
        method: PUT
        state: users

      # DELETE item - removes from state
      - path: /users/:id
        method: DELETE
        state: users

      # Conditional Headers & Response matching
      - path: /status
        method: GET
        rules:
          - if: "headers.x-api-key != 'secret'"
            status: 401
            body: { "error": "Unauthorized" }
        default:
          status: 200
          body: { "status": "healthy" }

  - name: payment-service
    host: payment.local
    routes:
      - path: /charge
        method: POST
        default:
          status: 200
          body: { "chargeId": "ch_12345", "status": "succeeded" }

🛡️ Architecture & Request Life Cycle

                      [ Client Request ]
                              │
                              ▼
                      [ Resolves Tenant ]
                     ├── Host Match: host.local
                     └── Prefix Match: /prefix
                              │
                              ▼
                      [ Matches Route ]
                     (Method + Path Pattern)
                              │
                              ▼
                     [ Evaluates Rules ]
             (Evaluates conditions against request)
                ├── Match? ──► Return custom response
                └── No Match
                              │
                              ▼
                     [ Stateful CRUD? ]
                ├── Yes ──► Read/Write state store (RAM)
                └── No  ──► Return route default

🤝 Verification & Manual Testing

  1. Start MockForge:
    npx mockforge-gateway --config mockforge.yaml
  2. Fetch all users (GET collection):
    curl http://localhost:8080/auth/users
  3. Insert a new user (POST):
    curl -X POST -H "Content-Type: application/json" -d '{"name": "Alice"}' http://localhost:8080/auth/users
  4. Fetch all users again to verify the state was updated:
    curl http://localhost:8080/auth/users
  5. Verify path param matching and rules:
    curl http://localhost:8080/auth/users/404

📜 License

This project is licensed under the MIT License. See LICENSE for details.