lacspace-mock
Keyless local mock REST + GraphQL API from a JSON file.
npx lacspace-mock --db db.jsonEverything, in one command
Frontend teams shouldn't have to wait for a backend to exist. lacspace-mock reads a db.json and instantly serves REST CRUD for every collection, answers custom routes described in a small JSON config (templated with path params, request-body fields and a seeded faker), and resolves a pragmatic GraphQL subset — all on node:http with no runtime dependencies. Because the same engine is an importable, port-free library, it doubles as a test fixture: construct a request, assert the response, no sockets. Latency and error-rate knobs let you rehearse loading states and failure handling before you ever hit a real server.
What's inside
Auto REST CRUD
Every JSON collection becomes GET/POST/PUT/PATCH/DELETE with proper status codes and headers.
Rich list queries
Pagination, multi-key sort, field filters, _gte/_lte/_ne/_like operators and full-text q.
Templated custom routes
{{params}}, {{query}}, {{body}}, {{repeat n}} and a seeded faker ({{fake.email}}, {{fake.uuid}}…).
Network simulation
Global/per-route delay (fixed or jitter) and an --error-rate chaos switch for random 500s.
Minimal GraphQL
One POST /graphql resolves collection queries with id/limit args and nested field selection.
Library + CLI
A pure, port-free createEngine().handle() makes it unit-testable and embeddable.
Private by default
Binds to 127.0.0.1, CORS on, --write to persist, zero deps, no telemetry.
Copy, paste, done
Real commands and snippets — from a one-liner to the typed library.
npx lacspace-mock --db db.jsonCRUD for every collection at http://127.0.0.1:4000.
curl 'localhost:4000/users?role=admin&_sort=age&_order=desc&_limit=10'operators, q, and X-Total-Count header included.
npx lacspace-mock --config mock.config.jsontemplated routes with {{params}}, {{body}}, {{fake.*}}, {{repeat}}.
npx lacspace-mock --db db.json --delay 50-400 --error-rate 0.1jittered latency + 10% random 500s.
curl -X POST localhost:4000/graphql -d '{"query":"{ users(id:1){ id name } }"}'pragmatic subset: id/limit args, nested selection.
What people build with it
✓ Prototype a UI before the backend exists
✓ Deterministic API fixtures for integration tests
✓ Rehearse loading/error states with latency + chaos
✓ Local contract stubs for a third-party API
Run lacspace-mock today
Free, open-source, no API keys. It's a CLI and a typed library.
npx lacspace-mock --db db.json