koa-lite/benchmarks/middleware.js
Slobodan Stojanovic 6d3b81fe50 Update benchmark, remove --harmony flag and use arrow functions
closes #567

Fix benchmark middleware - in promises body is on ctx not on this
2015-10-28 14:26:04 -07:00

21 lines
373 B
JavaScript

'use strict';
const http = require('http');
const Koa = require('..');
const app = new Koa();
// number of middleware
let n = parseInt(process.env.MW || '1', 10);
console.log(` ${n} middleware`);
while (n--) {
app.use((ctx, next) => next());
}
const body = new Buffer('Hello World');
app.use((ctx, next) => next().then(() => ctx.body = body));
app.listen(3333);