@yoyo-org/mockr
v0.3.3
Published
Endpoints are named data holders. Define a URL, attach data, and get a mock API server.
Readme
mockr
Mock API server for frontend prototyping. Define endpoints with data, get full CRUD for free. Mock the routes you're building, proxy the rest to a real backend. WebSocket endpoints, scenarios, zod validation, and a Chrome extension that records traffic and maps it to local files.
Docs: https://yoyo-67.github.io/mockr/
Install
npm install @yoyo-org/mockr zodAdd "type": "module" to package.json. Run with npx tsx mock.ts — no build step.
Quick example
import { mockr } from '@yoyo-org/mockr';
await mockr({
port: 4000,
endpoints: [
{ url: '/api/todos', data: [{ id: 1, title: 'Buy milk', done: false }] },
],
});GET /api/todos returns the array. POST inserts. PATCH /api/todos/1 updates. DELETE /api/todos/1 removes. No glue code.
Where to next
- Concepts — the data-driven mental model
- Tutorial — eleven chapters, each a runnable example
- Reference — full API surface (handlers, WebSocket, recorder, CLI)
- Examples — copy-pasteable working servers
License
MIT
