urlproxy
set a proxy for url using stream
Install
$ npm install urlproxy -g
Usage
var proxy = require('urlproxy');
proxy('a.js').pipe(res);
It will find the file in local directory. if not found, it will find from the proxy server, and cache to local if cache option is true.
custom ready
event, when stream can be ready to pipe, when you use express or koa.
proxy('a.js')
.on('ready', function() {
res.statusCode = 200;
})
.on('error', function() {
res.statusCode = 404
res.end('Not Found');
})
.pipe(res);
Option
- directory: local directory, default
process.cwd()
, - proxy: set remote server
- cache: cache remote file
- followRedirect: follow redirect when 302
LISENCE
Copyright (c) 2014 popomore. Licensed under the MIT license.