npm package: 360-mock-server
Description: 🚀 Zero-config dynamic mock REST API server with Faker.js auto-generation for frontend developers
Author: zahidrahimoon
Latest version: 1.2.8

# 🚀 360 Mock Server

**360 Mock Server** is a zero-config mock REST API for frontend developers.
Create, update, delete, paginate, and auto-generate fake data **without building a backend**.

Perfect for **React / React Native / Redux / demos / testing**.


## ✨ Features

* Zero configuration
* Works with **any REST endpoint**
* Full CRUD (GET, POST, PUT, PATCH, DELETE)
* **Fake data generation (Faker.js)**
* **Pagination & Sorting**
* **Full-text Search (?q=)**
* **Response Delay Simulation**
* **Error Rate Simulation**
* **Static File Serving (public/ folder)**
* Persistent JSON storage
* Interactive CLI + REST API
* CORS enabled


## 📦 Installation

```bash
npm install -g 360-mock-server
# or
npx 360-mock-server
```


## ⚡ Start Server

```bash
npx 360-mock-server
```

Server runs at:

```
http://localhost:5050
```


## 🧠 Manual + Faker + Pagination (All-in-One)

### ▶️ Manual CRUD (Normal API)

```bash
POST /users
{ "name": "Ali", "email": "ali@test.com" }

GET /users
GET /users/123

PATCH /users/123
{ "email": "new@test.com" }

DELETE /users/123
```

### 🎲 Faker.js – Auto Generate Fake Data

Just send `fields` array:

```bash
POST /users
{
  "fields": ["name", "email", "avatar", "phone"],
  "count": 10
}
```

Works for **any resource**:

```bash
POST /products
{
  "fields": ["productName", "price", "category"],
  "count": 20
}
```

Get all supported faker fields:

```bash
GET /faker/fields
```

### 📄 Pagination (Built-in)

```bash
GET /users?_page=1&_limit=5
```

Response:

```json
{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 5,
    "totalItems": 20,
    "totalPages": 4,
    "hasNextPage": true,
    "hasPrevPage": false
  }
}
```

* Pagination works on **any resource**
* If `_limit` is missing → returns full array

### 🔍 Full-text Search

Search across all fields in a resource:

```bash
GET /users?q=search_term
```

### ⏳ Delay & Error Simulation

Simulate slow networks or server failures:

```bash
# Global delay for all requests
GET /users?_delay=1000

# Global settings via CLI (see Options)
```


## 💻 Frontend Usage

### Fetch

```js
fetch('http://localhost:5050/users')
  .then(res => res.json())
  .then(console.log);
```

### Axios

```js
axios.get('http://localhost:5050/users', {
  params: { _page: 1, _limit: 10 }
});
```


## 🖥 Interactive CLI

After starting server:

```text
360-mock> POST /users {"name":"Ali"}
360-mock> GET /users
360-mock> DELETE /users/123
```

Commands:

* `list` – list resources
* `clear` – clear terminal
* `exit` – quit


## ⚙️ Options

```bash
npx 360-mock-server --port 4000
npx 360-mock-server --file db.json
npx 360-mock-server --delay 1000        # Add 1s delay to all responses
npx 360-mock-server --error-rate 10     # 10% chance of 500 Error
```


## 📂 Static Files

If a `public` folder exists in your project directory, files inside will be served automatically at the root.


## 💾 Storage

Data is stored locally in:

```
mock-data.json
```

## 🪪 License

MIT © [zahidrahimoon](https://github.com/zahidrahimoon)

Built with ❤️ for developers