koa-lite/benchmarks/experimental/async.js

29 lines
434 B
JavaScript
Raw Normal View History

2015-04-23 10:36:02 +00:00
'use strict';
const http = require('http');
const koa = require('../..');
const app = koa();
2015-04-23 10:36:02 +00:00
app.experimental = true;
// number of middleware
2015-10-11 23:24:42 +00:00
let n = parseInt(process.env.MW || '1', 10);
console.log(` ${n} async middleware`);
2015-04-23 10:36:02 +00:00
while (n--) {
app.use(async function (next){
await next;
});
}
const body = new Buffer('Hello World');
2015-04-23 10:36:02 +00:00
app.use(async function (next){
await next;
this.body = body;
});
app.listen(3333);