360-mock-server
v1.2.8
Published
π Zero-config dynamic mock REST API server with Faker.js auto-generation for frontend developers
Maintainers
Readme
π 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
npm install -g 360-mock-server
# or
npx 360-mock-serverβ‘ Start Server
npx 360-mock-serverServer runs at:
http://localhost:5050π§ Manual + Faker + Pagination (All-in-One)
βΆοΈ Manual CRUD (Normal API)
POST /users
{ "name": "Ali", "email": "[email protected]" }
GET /users
GET /users/123
PATCH /users/123
{ "email": "[email protected]" }
DELETE /users/123π² Faker.js β Auto Generate Fake Data
Just send fields array:
POST /users
{
"fields": ["name", "email", "avatar", "phone"],
"count": 10
}Works for any resource:
POST /products
{
"fields": ["productName", "price", "category"],
"count": 20
}Get all supported faker fields:
GET /faker/fieldsπ Pagination (Built-in)
GET /users?_page=1&_limit=5Response:
{
"data": [...],
"pagination": {
"page": 1,
"limit": 5,
"totalItems": 20,
"totalPages": 4,
"hasNextPage": true,
"hasPrevPage": false
}
}- Pagination works on any resource
- If
_limitis missing β returns full array
π Full-text Search
Search across all fields in a resource:
GET /users?q=search_termβ³ Delay & Error Simulation
Simulate slow networks or server failures:
# Global delay for all requests
GET /users?_delay=1000
# Global settings via CLI (see Options)π» Frontend Usage
Fetch
fetch('http://localhost:5050/users')
.then(res => res.json())
.then(console.log);Axios
axios.get('http://localhost:5050/users', {
params: { _page: 1, _limit: 10 }
});π₯ Interactive CLI
After starting server:
360-mock> POST /users {"name":"Ali"}
360-mock> GET /users
360-mock> DELETE /users/123Commands:
listβ list resourcesclearβ clear terminalexitβ quit
βοΈ Options
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
Built with β€οΈ for developers
