File-based mock toolkit for Vite, CLI builds, and runtime usage.
Website · Playground · GitHub
- File-based routing via filename suffixes like
users.get.json. - JSON/JSONC and TS/JS handlers powered by Hono Context.
- Works in Vite dev, CLI builds (workers), and runtime adapters.
- Built-in headers, status, delays, and middleware hooks.
- Node.js
^20.19.0 || >=22.12.0
- Published packages are ESM-only. CommonJS
require()is no longer supported. - Internal build packages now use
tsdownon top of Rolldown. - Shared build helpers are exposed from
@mokup/shared/rolldown.
Create mock/users.get.json:
{ "ok": true }Create mock/login.post.ts:
export default async (c) => {
const body = await c.req.json().catch(() => ({}))
return { ok: true, user: body }
}Tip: you can use defineHandler for better IntelliSense:
import { defineHandler } from 'mokup'
export default defineHandler(async (c) => {
const body = await c.req.json().catch(() => ({}))
return { ok: true, user: body }
})Follow the docs at https://mokup.icebreaker.top/ for Vite and CLI setup. Upgrade details: docs/guide/migration-v1.md
Issues and pull requests are welcome. See CONTRIBUTING.md.
pnpm run validate:fastpnpm run guard:migrationpnpm run typecheck:fastpnpm run lint:lines:guardpnpm typecheckpnpm lintpnpm testpnpm test:e2e:serial
Thanks to all contributors!
ice breaker hi@sonofmagic.top
Distributed under the MIT License. See LICENSE for more information.