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

postmock

v1.0.3

Published

Generate mock API servers from Postman collections or OpenAPI specs

Readme

PostMock

Instant Mock API Server Generator - Create mock servers from Postman collections or OpenAPI specs in seconds!

PostMock Cover

npm version npm downloads GitHub license GitHub issues

PostMock is a powerful interactive CLI tool that instantly generates mock API servers from your existing Postman collections or OpenAPI specifications. Perfect for frontend development, testing, and prototyping when you need a working API server without waiting for backend implementation.

✨ Features

  • 🚀 Instant Setup - Generate a mock server in seconds
  • 📚 Multiple Formats - Support for Postman (.json) and OpenAPI (.yaml/.yml/.json)
  • 🎭 Smart Mocking - Uses existing examples or generates realistic fake data
  • 🔄 Dynamic Responses - Generate different responses for each request
  • Hot Reload - Automatically restart server when files change
  • 🎯 CORS Support - Built-in CORS for frontend integration
  • ⏱️ Delay Simulation - Simulate network latency
  • 🐳 Docker Ready - Easy containerization
  • 📊 Health Checks - Built-in health monitoring endpoints
  • 💬 Interactive CLI - User-friendly prompts for all configuration options

🚀 Quick Start

Installation

npm install -g postmock

Basic Usage

Simply run the command and follow the interactive prompts:

postmock

The CLI will guide you through:

  • Selecting your input file (Postman collection or OpenAPI spec)
  • Choosing the port number
  • Setting up delay simulation
  • Enabling dynamic responses
  • Configuring CORS
  • Setting up hot reload

Example Interactive Session

🚀 Welcome to PostMock!
Generate mock API servers from Postman collections or OpenAPI specs

? Enter the path to your Postman collection (.json) or OpenAPI spec (.yaml/.json) file: examples/postman.json
? What port would you like to run the server on? 4000
? Enter simulated delay range in milliseconds (e.g., 100-300) or press Enter for no delay: 0
? Would you like to generate random responses for every request? No
? Enable CORS for cross-origin requests? Yes
? Enable hot reload to watch for file changes and restart server? No

✅ Mock API server running on http://localhost:4000

📖 Configuration Options

The interactive CLI will prompt you for the following settings:

| Setting | Description | Default | |---------|-------------|---------| | Input File | Path to your Postman collection or OpenAPI spec | Required | | Port | Port to run server on | 4000 | | Delay Simulation | Simulated delay range in ms (e.g., 100-300) | 0 (no delay) | | Dynamic Responses | Generate random responses every request | false | | CORS | Enable CORS for cross-origin requests | true | | Hot Reload | Watch for file changes and restart server | false |

🔧 Examples

Simple Mock Server

postmock
# Follow prompts to select your API file
# Server starts on default port 4000

Custom Configuration

postmock
# Select your OpenAPI spec file
# Choose port 5000
# Enable dynamic responses
# Set delay to 200-500ms
# Enable hot reload

📁 Input File Formats

Postman Collection

{
  "info": {
    "name": "My API Collection"
  },
  "item": [
    {
      "name": "Get Users",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/users",
          "host": ["{{baseUrl}}"],
          "path": ["users"]
        }
      },
      "response": [
        {
          "body": "{\"users\": [{\"id\": 1, \"name\": \"John Doe\"}]}"
        }
      ]
    }
  ]
}

OpenAPI Specification

openapi: 3.0.0
info:
  title: My API
  version: 1.0.0
paths:
  /users:
    get:
      summary: Get users
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              example:
                users:
                  - id: 1
                    name: John Doe

🎯 Use Cases

Frontend Development

  • Start building frontend immediately without waiting for backend
  • Test API integrations with realistic data
  • Develop offline-first applications

Testing & QA

  • Create consistent test environments
  • Test error handling with controlled responses
  • Performance testing with configurable delays

Prototyping

  • Demo API contracts to stakeholders
  • Rapid API design iteration
  • Proof of concept development

CI/CD

  • Automated testing against mock APIs
  • Consistent test environments
  • No external dependencies

🔌 API Endpoints

Health Check

GET /_health

Returns server status and endpoint count.

Mock Endpoints

All endpoints defined in your input file will be automatically created with appropriate HTTP methods and paths.

🤝 Contributing

We welcome contributions! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy Mocking! 🎭

Install NowView on GitHubReport Bug


Made with ❤️ by Win Khant Aung