Utility to compose Koa middleware functions into a single middleware. Current stable version is 4.1.0. Low release cadence; maintained as part of the Koa ecosystem. Key differentiator: it is the canonical middleware composition function for Koa, supporting async/await and error handling through promises. Alternatives like `koa-convert` or custom loops exist, but this is minimal and standard.
npm install koa-composeVerified import paths — ran on the pinned version, not inferred.
Demonstrates composing two Koa middleware functions (logger and responseTime) using compose, then applying to a Koa app.
Always wrap middleware in an array: compose([mw1, mw2])
Define middleware as async (ctx, next) => { await next(); }Use the returned function with app.use() or router middleware stack.
Ensure compose is called with an array: compose([func1, func2])
Ensure each middleware calls next() exactly once, or handle conditional logic properly.
Use proper import: import compose from 'koa-compose' or const compose = require('koa-compose')No dependency data recorded yet.