Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.