axl-mock-proxy
v1.0.5
Published
proxy module for test and development activities
Downloads
2
Maintainers
Readme
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