axl-mock-proxy

1.0.5 • Public • Published

axl-mock-proxy

proxy module for test and development activities, supports https request and response processing

Self generates CA certificates in order to process https requests.

Works out of the box, for custom behaviors like changed core logic - can be extended

Based on mockttp - visit for in-depth doc

Usage

import MockProxy from "@publishing/node-mock-proxy";
const proxy = new MockProxy("your name used for logs");

// ...processors can be added both before and after proxy is started
proxy.addRequestProcessor(({request, result}) => {
    if (request.url.match('stackoverflow.com')){
        result.url = request.url.replace('stackoverflow.com', 'you-suck.com')
    }
    return {request, result};
});

// ...this actually makes it alive - allows connections
await proxy.startProxy(port);

// ...if you don't pass `port` it will try to find free one. If you pass one that is busy - it will fail
const actualPort = proxy.port;

// ...do your stuff

// ...stop it once you're done
await proxy.stopProxy(); // your processors are cleared here !
// ...done

Package Sidebar

Install

npm i axl-mock-proxy

Weekly Downloads

10

Version

1.0.5

License

Apache-2.0

Unpacked Size

6.62 kB

Total Files

4

Last publish

Collaborators

  • axldns