node package manager


esteves - add, remove or inject content for a given webpage

Afterwards I lean back in the chair
And keep smoking.
As long as Destiny allows, I will keep smoking.
(If I married my washwoman's daughter
I might conceivably be happy.)
Given this, I rise and go to the window.
The man has come out of the Tobacco Shop (putting change into his pocket?).
Ah, I know him: he is Esteves without methaphysics.
(The Tobacco Shop owner has come to the door.)
As if by a divine instinct, Esteves turned around and saw me.
He waved hello, I shouted back "Hello there, Esteves!" and the universe
Reconstructed itself to me, without ideals or hope, and the owner of the Tobacco Shop smiled.

Tobacco Shop by Fernando Pessoa

Esteves is a small lib that allows for easy html rewriting as well as serving new resources. It builds upon node-http-proxy and trumpet.

The feature set is quite basic, but the src is very easy to read. Fork and change at will.

All my node projects will have a completely unrelated name, and I will further accompany the readme with a poem.

Is it any good?


Similar Projects


  • Support external config
  • Support regexes in uri definition
  • Support HTTPS


var http      = require('http'),
    httpProxy = require('http-proxy'),
    fs        = require('fs'),
    intercept = require('../')
// so that node doesn't hang on conn refused
process.on('uncaughtException', function(err) {
  console.log('uncaughtException: ', err);
var imgHeaders = {'Content-Type': 'image/gif', 'Pragma-directive': 'no-cache','Cache-directive': 'no-cache','Cache-control': 'no-cache','Pragma': 'no-cache','Expires': '0'};
var proxy = new httpProxy.createProxyServer();
//accept-encoding must be false, currently content-encoding is not supported (gzip)
var mware = new intercept.createMiddleware(proxy, {userAgent: 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36',
                                                   acceptEncoding: false});
mware.afterSelection('', 'head', function(cb){
    cb(null, '\n\t<script src="/myCustomScript.js"></script>\n');
mware.replaceSelection('', 'h1#logo', function(cb){
    cb(null, '<img id="ad_logo" src="/random_img.gif" onload="this.src=\'/asset/ad/logo.svg\';">');
mware.whenUri('', function(cb){
    cb(null, {code: 200, headers: imgHeaders, response: fs.readFileSync('examples/wwwroot/myCustomScript.js')});
mware.whenUri('', function(cb){
    cb(null, {code: 200, headers: imgHeaders, response: fs.readFileSync('examples/wwwroot/1x1.gif')});


MIT License.