Skip to content

cmtdrt/Mirage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mirage

Generate mock APIs instantly from JSON. No backend code needed.

Mirage is a lightweight Go CLI tool that turns a simple JSON file into a fully functional HTTP API server. Perfect for frontend development, testing, prototyping, and demos.

Quick Example

Create mirage.json:

{
  "endpoints": [
    {
      "method": "GET",
      "path": "/api/users",
      "response": {"users": [{"id": 1, "name": "Alice"}]}
    },
    {
      "method": "GET",
      "path": "/api/users/{id}",
      "response": {"id": "{id}", "name": "Alice"}
    }
  ]
}

Run mirage serve. Call GET /api/users/32 → the response will have "id": 32. Any {varName} in the response is replaced by the URL value.

Your API is now live on http://localhost:8080 !

Installation & Usage

# Build
go build -o mirage main.go

# Start with your config
mirage serve whatever-you-want.json

# Or use the built-in example
mirage serve --example

# Custom port
mirage serve --port=3000

# Multiple ports (one server instance per port, one log file per port)
mirage serve --ports=8080,8081,8082 mirage.json

What's Inside?

  • Path variables - /users/{id} matches any ID; put "{id}" in the response and it’s replaced by the URL value (numbers/decimals typed correctly)
  • Custom status codes - Return 201, 404, 500, etc.
  • Response delays - Simulate slow networks
  • Built-in health check - /health endpoint always available
  • Request logging - one log file per port: mirage-logs-{port}-{timestamp}.txt (e.g. mirage-logs-8080-20060102-150405.txt). One line per request. GET /logs returns logs for the port that served the request (JSON)
  • Auto-config detection - Just run mirage serve if mirage.json exists

Learn More

For complete documentation, examples, and advanced features:

mirage guide-en   # Generate English guide
mirage guide-fr   # Generate French guide

This creates mirage-guide-en.md or mirage-guide-fr.md with everything you need to know about Mirage.


Made with ❤️ by Myself

About

A tool that generates mock APIs from a JSON file to simulate real API calls and test endpoints without writing any code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors