Generated code, like fish, begins to smell after three days.
Agreed. Thanks, http://linemanjs.com/
We could have constructed a different myth, one in which the canonical image of a programmer depicted the activity "talking to a person who's going to use the software, to figure out what their needs are and how best to support them."Yes, that would be much better. I pledge to avoid playing broken telephone with those that really need the software I build, and I encourage my peers to do the same.
var http = require('http'), httpProxy = require('http-proxy');Install http-proxy (assuming you are using npm):
// initialize parametersvar listenPort = 5001, destinationPort = 5000, delay = 1000;
// router optionsvar options = { router: { '.*': 'localhost:' + destinationPort }};
// create server and listenvar server = httpProxy.createServer(function(req, res, next) { var delayedResponse = function() { next(); }; setTimeout(delayedResponse, delay);}, options);server.listen(listenPort);
npm install http-proxyAnd kick it:
node app.jsMaking hard coded parameters configurable is left as an exercise to the reader. Hint: process.argv gives you access to command line arguments in Node.