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

mockserverx

v0.0.12

Published

High-performance, easy-to-use mock API server written in Go. Supports live config reload, cross-platform binaries, and simple CLI interface.

Readme

MockServer Logo

Build Status npm License


Table of Contents


Overview

MockServer is a lightweight, configurable mock API server that allows developers to create realistic API endpoints using a single JSON configuration file. It is designed for both frontend developers and backend engineers to simulate API responses, test workflows, and prototype integrations without needing a fully functional backend.

Key features include:

  • Fully JSON-based configuration
  • Support for REST methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
  • Mock responses with delay simulation
  • Proxy/fetch real APIs dynamically
  • Authentication support (apiKey or Bearer)
  • CORS and default headers management

Purpose

Modern applications rely heavily on APIs. Developing frontend or integration tests often requires a backend that is not fully implemented yet. MockServer solves this problem by providing:

  • Fast prototyping: No need for real backend during early development
  • Realistic test scenarios: Support for dynamic response, headers, delays, and authentication
  • Flexible API simulation: Fetch real endpoints or mock static JSON files
  • Single source of truth: All routes, headers, and responses are managed in one JSON file

Installation

You can install MockServer using npm:

npm install -g mockserverx

Start the server:

mockserver start --config mockserver.json

Configuration

MockServer relies on a single JSON file, typically named mockserver.json, structured according to the JSON Schema. Below is a breakdown of the configuration options:

Server Configuration

"server": {
  "port": 3000,
  "api_prefix": "/v1",
  "default_headers": {
    "Content-Type": "application/json"
  },
  "default_delay_ms": 0,
  "cors": {
    "enabled": true,
    "allow_origins": ["*"],
    "allow_methods": ["GET","POST","PUT","DELETE"],
    "allow_headers": ["*"],
    "allow_credentials": false
  },
  "auth": {
    "enabled": true,
    "type": "apiKey",
    "name": "apiKey",
    "in": "query",
    "keys": ["secret"]
  }
}

Explanation:

  • port: Server listening port (1–65535)
  • api_prefix: Prefix for all API endpoints
  • default_headers: Headers applied to every response
  • default_delay_ms: Global response delay in milliseconds
  • cors: CORS configuration
  • auth: Global authentication configuration

Routes

Each route is an object inside the routes array:

{
  "name": "Get All Users",
  "tag": "Users",
  "method": "GET",
  "path": "/users",
  "auth": {
    "enabled": true,
    "type": "apiKey",
    "name": "apiKey",
    "in": "query",
    "keys": ["secret"]
  },
  "query": {
    "limit": {
      "type": "integer",
      "description": "Number of records to fetch",
      "required": false
    }
  },
  "fetch": {
    "url": "https://jsonplaceholder.typicode.com/users",
    "headers": {
      "Accept": "application/json"
    }
  }
}

Key properties:

  • name: Route display name
  • tag: Route grouping tag
  • method: HTTP method (GET, POST, etc.)
  • path: Endpoint path, supports path params {id}
  • auth: Optional route-specific authentication
  • query: Query parameters schema
  • path_params: Path parameter validation
  • body_schema: Request body validation (for POST, PUT, PATCH)
  • body_example: Example request body
  • mock: Local mock file configuration
  • fetch: Proxy to real API endpoint

Example Usage

Start Server

mockserver start --config mockserver.json

Call Endpoint

curl http://localhost:3000/v1/users?apiKey=secret

Mock Local JSON

{
  "name": "List Todos (Mock)",
  "tag": "Todos",
  "method": "GET",
  "path": "/todos",
  "mock": {
    "file": "test/mocks/todos.json",
    "status": 200,
    "headers": {
      "X-Source": "MockFile"
    },
    "delay_ms": 50
  }
}

Advanced Features

  • Delayed responses – simulate network latency
  • Dynamic fetch – route can forward requests to real APIs with path/query substitution
  • Authentication – supports apiKey in query/header or Bearer tokens
  • Swagger UI – generate API docs from mockserver.json (default /docs)