node package manager


A proxy image server


A proxy image server. This is a rewrite version of camo.

Install with npm:

$ npm install substitute -g
$ substitute -h
  Usage: substitute [options]
    -b, --bind <port>      The port or unix path to listen
    --host <host>          The hostname to listen [localhost]
    --path <path>          The pathname to listen [null]
    -c, --config <file>    Specify a configuration file
    -r, --redirects <num>  Max redirects allowed, default is 4
    -s, --secret <token>   A secret token to encrypto urls
    -V, --version          Display the version
    -h, --help             Display this help menu

Unlike camo, substitute supports only one URL Format:<reverse-domain>/<digest>/<image-path>

The <digest> is a 32 character hex encoded HMAC digest with a secret in md5 hash. And the <image-path> should be an ecoded/escaped replaced '/' uri.

You can get the browser client with component(1):

$ component install lepture/substitute

And generate new src with:

var substitute = require('substitute');
substitute.server = '';
substitute.secret = 'a secret that match the server secret';
var newSrc ='http://path/to/image');
// replace all image src 
var newHtml = substitute.image(html);

Test it manally, start a server:

$ substitute

And then visit: this link.

Test it automatically with mocha:

$ make test

You can also test the client part with:

$ make test-client
var substitute = require('substitute');
    maxRedirects: 5
var server = substitute(secret, options);