Convert express middleware to koa middleware
There is some difference between Express middleware and the converter, please see below.
npm install express-convert
const convert = require('express-convert'); const Koa = require('koa'); const app = new Koa(); app.use(convert(expressMiddleware));
||Custom JSON parser**|
* does not support custom callback name
** the custom parser only applies on the
res.jsonp() method because Koa will parse JSON for you in other cases.
req.app: req.app is a
Koaapp instance, not an
- Application Setting: The only setting implemented now is
jsonp callback namefor
req.cookies: Koa uses the
cookiesmodule so this property is not a parsed cookie object, for what it is, see Koa documents.
req.route: Koa does not have router, so the properties is always
undefinedand the method always returns
undefinedand do nothing.
req.signedCookies: this property is
req.range(): Koa dones't support this, so this function always return undefined and do nothing.
res.locals: Koa dones't support this, so this would be a empty object.
res.cookie: Koa uses the
cookiemodule to do the job, so the option is a little bit different, for more information, see Koa documents.
res.clearCookie(): Koa does not support it, so this function will always return undefined and do nothing.
res.sendFile(): Koa does not support it, so this function will always return undefined and do nothing, consider use
res.attach()to do file hosting job.
res.end(): This generally does nothing because in Koa you do not need to end the response manually, just do nothing. Koa will end the response automatically.
res.jsonp(): Koa does not have integrated support for this method, this is only a simple implementation. For better jsonp support, have a look at koa-jsonp.
res.links(): Koa does not have integrated support for them, but I plan to implement them in future versions, now they generally do nothing.
res.render(): Koa does not support this, so it does nothing.