lacspace-mock

Keyless local mock REST + GraphQL API from a JSON file.

● Live · v0.1.0npmSource
terminal
npx lacspace-mock --db db.json
What it does

Everything, 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.

Features

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.

How to use

Copy, paste, done

Real commands and snippets — from a one-liner to the typed library.

Serve a JSON db
terminal
npx lacspace-mock --db db.json

CRUD for every collection at http://127.0.0.1:4000.

Filter, sort, paginate
terminal
curl 'localhost:4000/users?role=admin&_sort=age&_order=desc&_limit=10'

operators, q, and X-Total-Count header included.

Custom + fake data
terminal
npx lacspace-mock --config mock.config.json

templated routes with {{params}}, {{body}}, {{fake.*}}, {{repeat}}.

Rehearse a slow, flaky API
terminal
npx lacspace-mock --db db.json --delay 50-400 --error-rate 0.1

jittered latency + 10% random 500s.

GraphQL over the db
terminal
curl -X POST localhost:4000/graphql -d '{"query":"{ users(id:1){ id name } }"}'

pragmatic subset: id/limit args, nested selection.

Good for

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

Start now

Run lacspace-mock today

Free, open-source, no API keys. It's a CLI and a typed library.

terminal
npx lacspace-mock --db db.json