New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-convert

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-convert

Convert Express middleware to Koa middleware

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

express-convert

Convert express middleware to koa middleware
There is some difference between Express middleware and the converter, please see below.

Install

npm install express-convert

Usage

const convert = require('express-convert');
const Koa = require('koa');
const app = new Koa();

app.use(convert(expressMiddleware));

Express Compatibility

express-convertexpress
@1@4

Feature

Versionres.jsonp()Custom JSON parser**
1.2.0:x::x:
1.3.0:o:*:x:
1.3.1:heavy_check_mark::x:
1.4.0:heavy_check_mark::heavy_check_mark:

* 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.

Some differences

  • req.app: req.app is a Koa app instance, not an Express app instance.
  • Application Setting: The only setting implemented now is jsonp callback name for res.jsonp().
  • req.cookies: Koa uses the cookies module so this property is not a parsed cookie object, for what it is, see Koa documents.
  • req.params, req.app.METHOD() and req.route: Koa does not have router, so the properties is always undefined and the method always returns undefined and do nothing.
  • req.signedCookies: this property is undefined, use req.cookies.get() with signed option.
  • 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 cookie module 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.download() and 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.location() and 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.

Keywords

FAQs

Package last updated on 24 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc