Note: try to build a compatible express' response for koa2
npm install --save koay-res
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();
});