Middleware for Koa that mocks REST APIs or backend services by matching routes to configurable responses. Version 1.0.0 requires Node >=10. Allows static/conditional/dynamic responses via JSON config or custom modules. Tightly coupled to Koa’s response API; no standalone usage. Low release cadence (no updates since 2020).
npm install koa-mock-responseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Starts a Koa server that mocks two endpoints: a 200 JSON response and a 500 error.
Consolidate all mocks into a single config object or use multiple Koa apps on different ports.
Use 'response' for a single response, 'responses' for an array with conditional logic.
Use path.resolve(__dirname, 'path/to/module') for relative paths.
Consider forking or migrating to a more active mock library like @wesleytodd/koa-mock.
Ensure Koa version is >=2 but the middleware works with Koa 2's async/await style; actual issue is missing config object.
Run: npm install koa-mock-response
Call koaMockResponse({ mocks: [...] }) and pass result to app.use.