npm.io
0.1.1 • Published 12 years ago

urlproxy

Licence
MIT
Version
0.1.1
Deps
6
Vulns
5
Weekly
0

urlproxy

NPM version Build Status Build Status NPM downloads

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.