Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-convert

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-convert

convert koa legacy generator-based middleware to promise-based middleware

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
decreased by-55.46%
Maintainers
1
Weekly downloads
 
Created

What is koa-convert?

The koa-convert npm package is designed to help transition from Koa's old middleware signature (generator functions) to the new middleware signature (async functions). It wraps Koa's old generator-based middleware to be compatible with the new Koa v2.x async middleware signature. This allows developers to use legacy middleware that hasn't yet been updated to the new format, facilitating a smoother upgrade path to Koa v2.x.

What are koa-convert's main functionalities?

Converting generator-based middleware

This feature allows you to wrap old Koa middleware that uses generator functions into a form that's compatible with Koa v2.x's async middleware. The code sample demonstrates how to convert a simple timing middleware to the new format.

const convert = require('koa-convert');
const oldMiddleware = function *(next) {
  const start = new Date;
  yield next;
  const ms = new Date - start;
  console.log(`${this.method} ${this.url} - ${ms}ms`);
};

app.use(convert(oldMiddleware));

Other packages similar to koa-convert

Keywords

FAQs

Package last updated on 16 Nov 2015

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