# abs-proxy

> HTTP proxying with ability to override or define routes

Latest version **0.7.4** (published 2016-02-09) · 0 weekly downloads

## Install

```sh
npm install abs-proxy
pnpm add abs-proxy
yarn add abs-proxy
bun add abs-proxy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.4 |
| Published | 2016-02-09 |
| First published | 2016-01-18 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Unbxd Inc., |
| Maintainers | basavanagowda |

## Links

- npm: https://www.npmjs.com/package/abs-proxy
- Repository: https://github.com/unbxd/node-abs-proxy
- Homepage: https://github.com/unbxd/node-abs-proxy#readme
- Issues: https://github.com/unbxd/node-abs-proxy/issues
- npm.io page: https://npm.io/package/abs-proxy

## Dependencies (2)

- [http-proxy](https://npm.io/package/http-proxy.md) ^1.12.0
- [httpdispatcher](https://npm.io/package/httpdispatcher.md) ^0.4.0

## Recent versions

- 0.7.4 (latest) — 2016-02-09
- 0.7.3 — 2016-01-18
- 0.7.2 — 2016-01-18

## README

# abs-proxy
HTTP proxying with ability to override existing routes or define new routes.

[![Build Status](https://travis-ci.org/unbxd/node-abs-proxy.svg?branch=master)](https://travis-ci.org/unbxd/node-abs-proxy)

### Usage
##### Require & instantiate
```javascript
var absProxy = require('abs-proxy');

var proxy = absProxy.createAbsProxy({host: 'httpbin.org', port: 80});
```

##### As a proxy
Lets create a reverse proxy to [httpbin](https://httpbin.org/):

```javascript
var http = require('http');
http.createServer(function(req, res) {
  proxy.dispatch(req, res);
}).listen(8080, 'localhost');
```

Note that default value for `port` is 80 and can be skipped from being included in the parameter hash for `Proxy`.

##### Override an existing path
###### GET
```javascript
proxy.onGet('/', function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello, world!\n');
});

var http = require('http');
http.createServer(function(req, res) {
    proxy.dispatch(req, res);
}).listen(8080, 'localhost');
```

###### POST
```javascript
proxy.onPost('/post', function(req, res) {
    res.writeHead(201, {'Content-Type': 'text/plain'});
    res.end('You just posted!\n');
});

var http = require('http');
http.createServer(function(req, res) {
    proxy.dispatch(req, res);
}).listen(8080, 'localhost');
```

##### Implement a new path
###### GET
```javascript
proxy.onGet('/non-existant-path', function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello, world!\n');
});

var http = require('http');
http.createServer(function(req, res) {
    proxy.dispatch(req, res);
}).listen(8080, 'localhost');
```

###### POST
```javascript
proxy.onPost('/non-existant-path', function(req, res) {
    res.writeHead(201, {'Content-Type': 'text/plain'});
    res.end('You just posted!\n');
});

var http = require('http');
http.createServer(function(req, res) {
    proxy.dispatch(req, res);
}).listen(8080, 'localhost');
```

---
_Source: https://npm.io/package/abs-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
