MockM - The Ultimate API Development Companion πŸš€

July 25, 2025 Β· View on GitHub

One-stop API mocking and debugging platform for seamless frontend-backend parallel development

δΈ­ζ–‡ | English | πŸ“š Documentation

Downloads Version License Stars

MockM Interface Preview

✨ Core Features

🎯 Zero Configuration - Get started with 2 commands, instant API server
πŸ”„ Smart Proxy - Non-invasive CORS solution, goodbye to CORS headaches
πŸ“Š Data Generation - Built-in MockJS for realistic data generation
🎭 Restful API - Auto-generated CRUD endpoints, doubled development efficiency
πŸ•ΈοΈ WebSocket Support - Complete real-time communication solution
πŸ“± Visual Management - Intuitive Web UI with drag-and-drop API management
πŸ”„ Request Replay - One-click replay of historical requests
🌐 Remote Debugging - Built-in tunneling for anywhere collaboration
⚑ Hot Reload - Real-time configuration updates, smooth development experience

πŸš€ Quick Start

Get Started in 1 Minute

# Global installation
npm i -g mockm

# Start with examples
mm --config

πŸŽ‰ That's it! You now have:

Experience Immediately

πŸ’‘ Tip: The --config parameter creates an example configuration with common feature demonstrations

πŸ’‘ Core Features Showcase

🌍 CORS Proxy - Solve All CORS Issues with One Line

Problem: Always frustrated by CORS errors in frontend development?
Solution: MockM eliminates CORS headaches forever!

# Simplest CORS proxy
mm proxy=http://your-backend:8080

Or use a configuration file:

module.exports = {
  proxy: 'http://your-backend:8080'
}

Result: Your original http://your-backend:8080/api/users now works through http://127.0.0.1:9000/api/users with automatic CORS handling!

🎭 Instant APIs - Create Complete Endpoints with 3 Lines

module.exports = {
  api: {
    '/my/awesome/api': {
      message: 'My first API',
      data: { success: true }
    }
  }
}

Instantly available: http://127.0.0.1:9000/my/awesome/api

πŸ”„ Restful API Generator - Complete CRUD with One Config

Want a complete blog system? Just do this:

module.exports = {
  db: {
    posts: [
      { id: 1, title: 'My First Blog', content: 'Using MockM is incredibly simple!' }
    ]
  }
}

Instantly get:

  • GET /posts - Get all posts
  • GET /posts/1 - Get specific post
  • POST /posts - Create new post
  • PUT /posts/1 - Update post
  • DELETE /posts/1 - Delete post
  • GET /posts?q=keyword - Search posts

πŸ“Š Smart Data Generation - Deep MockJS Integration

module.exports = util => ({
  db: {
    users: util.libObj.mockjs.mock({
      'data|20-50': [{
        'id|+1': 1,
        name: '@name',              // Random name
        email: '@email',            // Random email
        avatar: '@image("200x200")', // Random avatar
        'age|18-65': 1,            // Random age 18-65
        address: '@county(true)'    // Random address
      }]
    }).data
  }
})

πŸ› οΈ Response Interception & Modification - No Backend Cooperation Needed

Need to modify backend response data? Easy:

module.exports = {
  proxy: {
    '/': 'http://your-backend:8080',
    '/api/user': ['data.name', 'John Doe'], // Change username to John Doe
    '/api/status': ['success'] // Return "success" directly
  }
}

⏱️ API Delay Simulation - Test Slow Network Conditions

module.exports = {
  proxy: {
    '/api/slow': {
      mid(req, res, next) {
        setTimeout(next, 3000) // 3-second delay
      }
    }
  }
}

πŸ”Œ WebSocket Support - Real-time Communication Made Easy

module.exports = {
  api: {
    'ws /chat'(ws, req) {
      ws.send('Welcome to the chat room!')
      ws.on('message', msg => {
        ws.send(`Echo: ${msg}`)
      })
    }
  }
}

πŸ“± Visual Management - Drag-and-Drop API Management

Easily manage APIs through Web UI:

  • πŸ“‹ View all API endpoints
  • πŸ” Search and filter APIs
  • ✏️ Edit API logic online
  • πŸ“Š View request history and statistics
  • πŸ”„ One-click replay historical requests

🌐 Remote Collaboration - One-click Tunneling

module.exports = {
  remote: true // Enable remote access
}

Auto-generate public URLs supporting:

  • 🌍 Remote team collaboration
  • πŸ“± WeChat mini-program development
  • πŸ”— Third-party service integration

πŸ† Use Cases

πŸ‘¨β€πŸ’» Frontend Developers

  • Quick Setup Mock services without waiting for backend
  • CORS Solution One line of code solves all CORS issues
  • Data-Driven Develop with realistic data

πŸ‘©β€πŸ’» Backend Developers

  • API Documentation Auto-generated docs for smoother frontend integration
  • Request Parameters One-click sharing, no more screenshot parameters
  • Debug Tools Complete request history tracking

🎯 QA Engineers

  • API Testing Built-in Postman-like tools
  • Data Simulation Easy testing of edge cases
  • Performance Testing Delay and error simulation

πŸ‘₯ Team Collaboration

  • Remote Debugging One-click public URL generation
  • Version Control Git-friendly configuration files
  • Environment Isolation Flexible multi-environment configs

πŸ“Έ Interface Preview

πŸ–±οΈ Click to view more interface screenshots

Request Record Details
Request Record Details

API Request History
API Request History

Visual API Editor
Visual API Editor

πŸ†š Feature Comparison

πŸ“Š Comprehensive Feature Matrix

FeatureMockMMockJSJSON-ServerYApi/Rap2Postman MockWiremockMSWFaker.jsApifox
πŸš€ Zero Configβœ…βŒβœ…βŒβŒβŒβŒβŒβŒ
🌐 CORS Handlingβœ… AutoβŒβŒβŒβŒβœ…βœ…βŒβŒ
πŸ“Š Data Generationβœ… Built-in MockJSβœ…βŒβœ…πŸ”Ά BasicπŸ”Ά Basicβœ…βœ…βœ…
πŸ”„ Restful APIβœ… Auto-generatedβŒβœ…βŒβŒβœ…βŒβŒβŒ
πŸ•ΈοΈ WebSocketβœ…βŒβŒβŒβŒβŒβŒβŒβŒ
πŸ“± Visual Managementβœ…βŒβŒβœ…βœ…πŸ”Ά 3rd partyβŒβŒβœ…
πŸ”„ Request Replayβœ…βŒβŒβŒβœ…βœ…βŒβŒβœ…
🌍 Remote Debuggingβœ… Built-in tunnelingβŒβŒβœ…βœ… CloudβŒβŒβŒβœ… Cloud
⚑ Hot Reloadβœ…βŒβœ…βŒβŒβœ…βœ…βŒβŒ
πŸ› οΈ Response Interceptionβœ…βœ… Frontend onlyβŒβŒβœ…βœ…βœ…βŒβœ…
πŸ’» RuntimeNode.jsBrowserNode.jsJava/DockerCloudJavaBrowser/NodeNode.jsDesktop/Cloud
πŸ’° CostFreeFreeFreeFree/PaidFree/PaidFreeFreeFreeFree/Paid

🎯 Tool Positioning

Data Generation Tools

  • MockJS: Frontend-only data mocking, no real network requests visible
  • Faker.js: Data generation library only, requires building your own server
  • MockM: Built-in MockJS + complete server, ready to use

API Server Tools

  • JSON-Server: Simple REST API generation, no data generation or CORS features
  • WireMock: Powerful Java ecosystem mock server, complex configuration
  • MockM: Express ecosystem, simple configuration, comprehensive features

Testing Tools

  • Postman Mock: Cloud-based mock service, requires internet, relatively basic features
  • MSW: Focused on test environment request interception, steep learning curve
  • MockM: Development + testing dual-purpose, local-first, cloud-expandable

Platform Tools

  • YApi/Rap2: Enterprise API management platform, complex deployment
  • Apifox: Commercial all-in-one API tool, powerful but paid features
  • MockM: Lightweight local tool, focused on development efficiency

πŸ’‘ Selection Guide

Use CaseRecommended ToolReason
πŸš€ Rapid PrototypingMockMZero config, instant start
πŸ§ͺ Frontend Unit TestingMSW + Faker.jsProfessional testing toolchain
🏒 Enterprise API ManagementYApi + MockMDocumentation + development debugging
☁️ Team CollaborationApifox / MockM RemoteCloud collaboration
🎯 Java Backend TestingWireMockJava ecosystem integration
πŸ“Š Pure Data GenerationMockJS / Faker.jsLightweight solution

❓ Common Misconceptions Clarified

πŸ€” "What's the difference between MockM and MockJS?"

  • MockJS: Only intercepts XHR requests in browser, no real network requests
  • MockM: Runs a real server, visible in Network panel, supports CORS

πŸ€” "Isn't MockM the same as JSON-Server?"

  • JSON-Server: Only generates simple REST APIs, no data generation capabilities
  • MockM: REST API + Data Generation + Proxy + Visual Management + Remote Debugging

πŸ€” "Why not just use Postman Mock?"

  • Postman Mock: Cloud service, requires internet, relatively basic features, complex setup
  • MockM: Local-first, comprehensive features, zero-config start, optional cloud mode

πŸ€” "MSW looks powerful too?"

  • MSW: Focused on testing environments, mainly for unit and integration tests
  • MockM: Focused on development environments, provides complete dev server solution

πŸ€” "We already have YApi/Apifox, do we still need MockM?"

  • YApi/Apifox: Heavy on documentation and team collaboration, still need local tools for development
  • MockM: Perfect complement, focused on development efficiency, works great with documentation platforms

🀝 Community & Support

πŸ“š Documentation & Tutorials

ProjectDescription
🎨 TaroifyTaro version of mobile component library Vant, accelerating mini-program development
🎯 wot-design-uniVue3+TS uni-app component library with 70+ high-quality components

If you have a project that needs to be showcased on this page, please let me know.

πŸ’¬ Communication & Feedback

πŸ“„ License

This project is licensed under MIT

Copyright (c) 2017-present, xw


⭐ If this project helps you, please give us a Star!

GitHub stars