An open API service indexing awesome lists of open source software.

https://github.com/xatrarana/mockini

Mock REST API server from a JSON config
https://github.com/xatrarana/mockini

cli json mock-server rest-api

Last synced: 11 months ago
JSON representation

Mock REST API server from a JSON config

Awesome Lists containing this project

README

          

# โšก mockini

mockini is a lightweight CLI tool to instantly spin up mock REST APIs using a simple JSON config file.
Designed for frontend developers, testers, and backend teams who need mock endpoints without writing server logic.

---

## ๐Ÿš€ Features

- โšก Zero-config mock server
- ๐Ÿ›  Simple JSON-based route definition
- ๐Ÿงฉ Supports GET, POST, PUT, DELETE, etc.
- โœจ CLI: `init` to generate config, `start` to launch server
- ๐Ÿง  Convention-based: uses `mockini.config.json` by default
- ๐Ÿ‡ Built with Bun (but runs as a native CLI via npx/npm)

---

## ๐Ÿ“ฆ Getting Started

### 1. Create a config file

```bash
npx mockini init
```

Creates a file: `./mockini.config.json`

You can also manually create it:

```json
{
"port": 3000,
"routes": [
{
"method": "GET",
"path": "/hello",
"status": 200,
"response": { "message": "Hello, world!" }
}
]
}
```

---

### 2. Start the mock server

```bash
npx mockini start
```

By default, it uses `./mockini.config.json`.
You can override the path with:

```bash
npx mockini start --config ./myconfig.json
```

You can also install globally:

```bash
npm install -g mockini
mockini init
mockini start
```

---

## ๐Ÿงฉ CLI Commands

| Command | Description |
| --------------- | ----------------------------------- |
| `mockini init` | Generate a default mock config file |
| `mockini start` | Start mock server from config file |

---

## ๐Ÿ“ Project Structure

```bash
mockini/
โ”œโ”€โ”€ bin/ # CLI entry point
โ”œโ”€โ”€ src/ # Server and init logic
โ”œโ”€โ”€ docs/ # Additional documentation
โ”œโ”€โ”€ mockini.config.json # Default config (generated)
โ”œโ”€โ”€ README.md # This file
```

---

## ๐Ÿ›  Tech Stack

- ๐Ÿ‡ Bun (development runtime)
- ๐Ÿงช Express (mock server)
- ๐Ÿงพ Commander (CLI parser)

---

## ๐Ÿ“„ License

MIT ยฉ 2025 Chhatra Rana