Registry / devops / koa-express-adapter

koa-express-adapter

JSON →
library1.0.0jsnpmunverified

Adapter for using Express middleware in Koa applications. Version 1.0.0 allows wrapping Express-compatible middleware functions (req, res) to be used within Koa's middleware chain. Supports many Express request and response APIs but not all. Limited release; no recent updates. Differentiators: enables Express middleware reuse during migration from Express to Koa.

npm install koa-express-adapter
INSTALL
IMPORT
SIG · KOA-EXPRESS-ADAPTE
K
koa-express-adapter
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wrap
const { wrap } = require('koa-express-adapter');
import { wrap } from 'koa-express-adapter';
Package is CJS only; ESM import will fail.
wrap (ESM)
import { wrap } from 'koa-express-adapter';
const koaExpress = require('koa-express-adapter'); const wrap = koaExpress.wrap;
Works with bundlers that support ESM, but native Node ESM may have issues.
Default import attempt
const adapter = require('koa-express-adapter'); const wrap = adapter.wrap;
import adapter from 'koa-express-adapter';
No default export; use named import wrap.

Demonstrates wrapping Express middleware to use in Koa, including basic usage and handling next().

const Koa = require('koa'); const { wrap } = require('koa-express-adapter'); const app = new Koa(); // Express middleware (no next argument) app.use(wrap((req, res) => { res.send('Hello from Express middleware!'); })); // With next argument (correct way) app.use(wrap((req, res, next) => { if (req.path === '/admin') { res.status(403).send('Forbidden'); } else { next(); } })); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
gotchaDo not define next argument if you don't use it; otherwise the adapter may behave unexpectedly.
fix
Omit next parameter from the wrapped function if you don't call next()
affects: >=1.0.0
gotchaExpress request/response properties not fully supported; check the list in README before relying on a property.
fix
Check supported properties in the README, or test the middleware.
affects: >=1.0.0
deprecatedPackage is no longer actively maintained; consider alternatives for new projects.
fix
Migrate to Koa native middleware or use a more maintained adapter like koa-connect.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: res.send is not a function
Express middleware expecting res.send but koa's res does not have that method; adapter intended to provide it but may fail for some properties.
fix
Use adapter's supported response methods; check the README for supported properties.
Error: next is not a function
Wrapped middleware with next argument but adapter did not pass next correctly.
fix
Include next parameter only if you call it; adapter requires exact signature.
TypeError: Cannot read property 'path' of undefined
Wrapped function expects req parameter but adapter may not pass it correctly if signature mismatched.
fix
Ensure wrapped function has exactly (req, res, next) or (req, res) without optional params.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
koa-express-adapter — npm install koa-express-adapter · libregistry