@anzerr/proxy.util

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

Usage no npm install needed!

<script type="module">
  import anzerrProxyUtil from 'https://cdn.skypack.dev/@anzerr/proxy.util';
</script>

README

Intro

GitHub Actions status | publish

Proxy request to a server transforming the headers or url

Install

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

Example

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);
});