zero-mock is a zero-config Node.js CLI that turns any JSON file into a persistent, production-grade REST API in seconds. It includes an interactive setup wizard, a high-contrast brutalist UI, and smart schema inference with automatic validation.
Built for frontend developers and architects who need a realistic, stable backend for prototypes, demos, and integration tests without the overhead of database orchestration.
- Zero-config — your JSON file is your database and API definition.
- Interactive wizard — run
zero-mockto start the setup guide. - Smart validation — automatically infers Zod schemas from your data to validate
POST,PUT, andPATCHrequests. - Atomic and secure — cross-platform atomic writes (Windows-safe) with file-locking to prevent data corruption.
- Advanced REST — supports filtering (
_gte,_lte,_like), sorting (_sort,_order), and pagination (_page,_limit). - Realistic simulation — simulate network latency and configure custom CORS origins/methods.
- Watch mode — hot-reloads data from disk on manual file changes without a server restart.
- Session memory — remembers your last used configuration for a faster workflow.
npm install -g @xirconsss/zero-mockRun the CLI as zero-mock.
npx @xirconsss/zero-mockRun the command without arguments to launch the setup wizard:
zero-mockPass flags to skip the wizard:
zero-mock -f ./data.json -p 8080 -w -d 200| Flag | Description |
|---|---|
-f, --file |
Path to the source JSON file. |
-p, --port |
HTTP port (default 3000, must be 1024–65535). |
-d, --delay |
Delay every request by X milliseconds (default 0). |
-w, --watch |
Enable hot-reloading on manual file changes. |
--cors-origin |
Comma-separated allowed origins (default *). |
--reset |
Clear saved wizard configuration and exit. |
The tool generates full CRUD endpoints for every top-level key in your JSON (e.g., users, posts).
| Method | Path | Description |
|---|---|---|
GET |
/{resource} |
List items (supports filtering, sorting, paging). |
POST |
/{resource} |
Create item (auto-id + schema validation). |
GET |
/{resource}/{id} |
Return a single item by id. |
PUT |
/{resource}/{id} |
Replace item (schema validation). |
PATCH |
/{resource}/{id} |
Partial update (schema validation). |
DELETE |
/{resource}/{id} |
Remove item. |
Filtering
GET /posts?category=tech— exact matchGET /posts?views_gte=100— greater than or equalGET /posts?title_like=hello— case-insensitive search
Sorting
GET /posts?_sort=createdAt&_order=desc
Pagination
GET /posts?_page=1&_limit=10- Returns an
X-Total-Countheader and a wrapped{ data, pagination }object.
The root must be an object, and every resource must be an array.
{
"users": [
{ "id": 1, "name": "Alice", "role": "admin" },
{ "id": 2, "name": "Bob" }
]
}Note: zero-mock automatically infers that role is an optional string based on the items above.
- Clone the repo.
npm installnpm run dev(runs withts-node)npm run build(compiles todist/)
This project uses semantic-release for fully automated versioning and npm publishing.
- Ensure your commits follow the Conventional Commits format (e.g.,
feat:,fix:,chore:). - Push or open a PR against the
mainbranch. - GitHub Actions handles testing, version bumping, changelog generation, and publishing to npm.
MIT — see LICENSE.
- Repository: github.com/xircons/zero-mock
- Issues: github.com/xircons/zero-mock/issues