npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

esteves

v0.0.4

Published

forward proxy that allows for custom content injection

Downloads

8

Readme

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?

Yes

Similar Projects

TODO

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

Example


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('http://my.site.pt/', 'head', function(cb){
	cb(null, '\n\t<script src="/myCustomScript.js"></script>\n');
});

mware.replaceSelection('http://my.site.pt/', 'h1#logo', function(cb){
	cb(null, '<img id="ad_logo" src="/random_img.gif" onload="this.src=\'/asset/ad/logo.svg\';">');
});

mware.whenUri('http://my.site.pt/myCustomScript.js', function(cb){
	cb(null, {code: 200, headers: imgHeaders, response: fs.readFileSync('examples/wwwroot/myCustomScript.js')});
});

mware.whenUri('http://my.site.pt/random_img.gif', function(cb){
	cb(null, {code: 200, headers: imgHeaders, response: fs.readFileSync('examples/wwwroot/1x1.gif')});
});

License

MIT License.