Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/popomore/urlproxy
set a proxy for url using stream
https://github.com/popomore/urlproxy
Last synced: about 2 months ago
JSON representation
set a proxy for url using stream
- Host: GitHub
- URL: https://github.com/popomore/urlproxy
- Owner: popomore
- Created: 2014-08-15T06:55:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-15T15:51:35.000Z (over 10 years ago)
- Last Synced: 2024-11-16T00:11:39.489Z (about 2 months ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
Awesome Lists containing this project
README
# urlproxy
[![NPM version](https://img.shields.io/npm/v/urlproxy.svg?style=flat)](https://npmjs.org/package/urlproxy)
[![Build Status](https://img.shields.io/travis/popomore/urlproxy.svg?style=flat)](https://travis-ci.org/popomore/urlproxy)
[![Build Status](https://img.shields.io/coveralls/popomore/urlproxy?style=flat)](https://coveralls.io/r/popomore/urlproxy)
[![NPM downloads](http://img.shields.io/npm/dm/urlproxy.svg?style=flat)](https://npmjs.org/package/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.