Mock server for API development
npm install @mocklite/cliZero-Configuration, SQLite-based Mock Server for Modern Frontend Development.


MockLite is a powerful, lightweight mock server designed to speed up frontend development. It auto-generates a full REST API based on a simple JSON schema, populates it with realistic data using Faker.js, and even simulates network conditions like slow connections or chaos modes.
- 🚀 Zero Boilerplate: Define a generic JSON config and get a full CRUD API instantly.
- 🌱 Realistic Seeding: Powered by Faker.js to generate thousands of realistic records.
- 🔍 Advanced Querying: Supports filtering, pagination, and Partial Search out of the box.
- 🔗 Relational Data: Automatically handles BelongsTo and HasMany relationships.
- ⚠️ Network Simulation: Built-in support for artificial latency (Delay) and Chaos Mode (Random Errors).
- 💾 Local Persistence: Uses SQLite, so your data persists between restarts (or resets if you choose).
- 🛠️ Interactive Mode: Shortcuts to re-seed or clear data while the server runs.
---
You can run MockLite directly using npx or install it globally.
``bashRun directly (Recommended)
npx @mocklite/cli init
$3
Run the initialization command in your project root. This creates a starter
mocklite.config.json file.`bash
npx @mocklite/cli init
`$3
Start the server using your configuration.
`bash
npx @mocklite/cli start
`You will see output indicating the server is running, listing available endpoints and active network simulations.
---
📚 Configuration Guide
The
mocklite.config.json file is the heart of your mock server.$3
`json
{
"port": 3000,
"database": "sqlite",
"delay": 500, // Optional: Global delay in ms
"errorRate": 0.0, // Optional: Probability of request failure (0.0 - 1.0)
"schema": [ ... ]
}
`$3
Each object in the
schema array represents a database table.`json
{
"table": "users",
"seed": 20, // Number of rows to auto-generate
"fields": {
"id": "pk", // Primary Key shortcut
"username": "faker.internet.userName",
"email": "faker.internet.email",
"avatar": "faker.image.avatar",
"role": {
"type": "enum",
"values": ["admin", "user", "guest"]
},
"isActive": {
"type": "faker.datatype.boolean",
"options": 0.9 // 90% true
}
}
}
`$3
| Type Def | Description | Example |
| :-------------------------- | :----------------------------------------------------------------------- | :---------------------------------------------------------------- |
|
"pk" | Primary Key. Auto-incrementing Integer. | "id": "pk" |
| "faker..." | Any valid Faker.js path. See Faker Docs. | "name": "faker.person.fullName" |
| "fk: