1.2.0 • Published 10 years ago

koa-response-length v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

koa-response-length

Emit events about response lenghts.

Example

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.

License

MIT