Skip to content

Try to build a compatible express' response for koa2

License

Notifications You must be signed in to change notification settings

koayjs/koay-res

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koay-res

npm package

Note: try to build a compatible express' response for koa2


Installation

Node >= 7.6

npm install --save koay-res

Usage

const compatRes = require('koay-res');
const Koa = require('koa');
const { middleware } = require('stylus');
const app = new Koa();
const fn = middleware( ... );

app.use(async (ctx, next) => {
  await new Promise((resolve, reject) => {
    fn(ctx.req, compatRes(ctx), (err) => {
      if (err) {
        reject(err);
      } else {
        resolve();
      }
    });
  });
  await next();
});

About

Try to build a compatible express' response for koa2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published