/connect-lag

Connect middleware for adding a random delay to responses

Primary LanguageJavaScriptBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

connect-lag

Connect middleware for adding a random delay to responses

Installation

For now, you can point your package.json file at this repository:

{
  "name": "cool-app",
  "dependencies": {
    "connect-lag": "git://github.com/localdata/connect-lag.git"
  }
}

Use

There are some examples in the examples folder, but roughly:

var connect = require('connect');
var lag = require('connect-lag');

var app = connect()
.use(lag({
  min: 250,
  max: 750
}))
.listen(process.env.PORT || 3000);

Why?

Sometimes we develop/test on our local machines, and things are just a little too snappy. This middleware helps us simulate an actual network connection without having to set up a separate proxy. It's not totally accurate, of course, since it modifies the server behavior and doesn't slow down each packet uniformly.