var responseLength =require('koa-response-length');
app.use(responseLength());
app.use(function*(){
this.body=someStream();
// also works with strings, buffers, json etc
});
app.on('response',function(len,ctx){
console.log('url: %s length: %s',ctx.url, len);
});
Installation
$ npm install koa-response-length
API
responseLength()
Create a middleware that makes the koa app emit response events whenever a
response is done, passing both the total response length and it's koa context.