Architecture
Core
The core package provides a generic Store with typed Collection<T> instances supporting CRUD, indexing, filtering, and pagination. Each service plugin registers its routes with the shared internal app and uses the store for state.
The internal HTTP layer builds on Hono's API and design. Thank you to Yusuke Wada and the Hono contributors. Hono's copyright and MIT license notice are included in THIRD_PARTY_NOTICES.md and distributed with the npm packages.
Plugin System
Each service is a plugin that:
- Defines its entity types and store collections
- Registers HTTP routes with the shared internal app
- Provides a seed function to populate initial state from config
- Uses shared middleware for auth, error handling, and pagination
Multiple services can run simultaneously, each on its own port (auto-incremented from the base port).
In-Memory State
All state is held in memory with no database. This makes the emulator fast, easy to reset, and ideal for CI pipelines. State is populated from the seed config on startup and can be modified via API calls during a test run.
Middleware
The core provides shared middleware:
- Auth: validates Bearer/token authorization headers against configured tokens
- Error handling: consistent error responses matching each service's format
- Pagination: GitHub-style
page/per_pagewithLinkheaders, Vercel-style cursor-based pagination
Custom emulators
Custom definitions created with defineEmulator from emulate work in the CLI, in-process tests, and both framework adapters. The same definition provides typed state, HTTP handlers, reset, versioned snapshots, and optional inspection/persistence. See Custom emulators for the quickstart, API reference, and complete lifecycle semantics.