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

https://github.com/anzerr/proxy.util


https://github.com/anzerr/proxy.util

http nodejs proxy util

Last synced: 5 months ago
JSON representation

Awesome Lists containing this project

README

          

### `Intro`
![GitHub Actions status | publish](https://github.com/anzerr/proxy.util/workflows/publish/badge.svg)

Proxy request to a server transforming the headers or url

#### `Install`
``` bash
npm install --save git+https://github.com/anzerr/proxy.util.git
npm install --save @anzerr/proxy.util
```

### `Example`
``` javascript
const Proxy = require('proxy.util'),
{Server} = require('http.server');

let proxy = new Proxy('https://www.google.com'),
http = new Server(8080);

proxy.on('request', (req) => {
console.log('forward url', req.url);
req.done();
});

http.create((req, res) => {
proxy.forward(req._req, res._res).catch((e) => {
res.status(500).send(e.toString());
});
}).then(() => {
console.log('started server on port', 8080);
});
```