A simple web proxy that lets you either return a status code for all requests or alter the response.
I use when testing out specific scenarios on mobile applications. I point the mobile app at this proxy, the proxy forwards the request, the proxy modifies the response before responding itself.
http://localhost:3000/setMode/404
Now all responses return 404.
http://localhost:3000/setMode/200
Behaviour returns to normal
var _ = require('lodash');
function filterOutASpecificRecord (body) {
var json = JSON.parse(body);
json.records = _.reject(json.records, {id: 37});
return json;
}
var proxy = require('everybody-needs-a-404');
proxy.modify('/records', filterOutASpecificRecord);
proxy.go('http://the-original-service.com:23423');
Now set the mode to altered and we are away.
http://localhost:3000/setMode/altered
var _ = require('lodash');
function newUrl (req) {
return "/newPath";
}
var proxy = require('everybody-needs-a-404');
proxy.rewriteUrl('/records/:id', newUrl);
proxy.go('http://the-original-service.com:23423');
Now set the mode to altered and we are away.
http://localhost:3000/setMode/altered
var _ = require('lodash');
function newUrl (req) {
return "/newPath";
}
function filterOutASpecificRecord (body) {
var json = JSON.parse(body);
json.records = _.reject(json.records, {id: 37});
return json;
}
var proxy = require('everybody-needs-a-404');
proxy.rewriteUrl('/records/:id', newUrl, filterOutASpecificRecord);
proxy.go('http://the-original-service.com:23423');
Now set the mode to altered and we are away.
http://localhost:3000/setMode/altered
http://localhost:3000/setDelay/1000
Now all requests will pause for a second before responding
http://localhost:3000/setDelay/0
Behaviour returns to normal.
Everybody Needs a 303. If the link doesn't work. Google it.