Skip to content

segment-boneyard/koa-response-length

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-response-length

Emit events about finished requests and their lengths.

build status

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