ebb4850709
closes #558 closes #557 Change tests to use plain functions and promises Add test return promise in middleware Change benchmarks to use plain functions and promises typeerror
27 lines
429 B
JavaScript
27 lines
429 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(function(ctx, next){
|
|
return next();
|
|
});
|
|
}
|
|
|
|
const body = new Buffer('Hello World');
|
|
|
|
app.use(function(ctx, next){
|
|
return next().then(function(){
|
|
this.body = body;
|
|
});
|
|
});
|
|
|
|
app.listen(3333);
|