koay-res

1.0.0 • Public • Published

koay-res

npm package

Note: build express middleware compatible with Koa


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();
});

Package Sidebar

Install

npm i koay-res

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

4.44 kB

Total Files

4

Last publish

Collaborators

  • fengxinming