-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
34 lines (23 loc) · 952 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// This will eventually become a command line version of the proxy. For now though, it's very broken.
var proxyFactory = require('./src/lib/proxy');
var onRequest = function(data) {
console.log('request: ' + data.method + ' ' + data.url);
};
var onResponse = function(data) {
console.log('response: ' + data.method + ' ' + data.url);
};
var httpProxy;
proxyFactory.createHttpProxy({port: 3002}).then(function(proxy) {
httpProxy = proxy;
proxy.on('proxyRequest', onRequest);
proxy.on('proxyResponse', onResponse);
proxy.on('proxyConnect', function(data) {
console.log('connect request: ' + data.state + ' ' + data.url + ':' + data.port);
});
return proxyFactory.createHttpsProxy({port: 8443});
})
.then(function(httpsProxy) {
httpsProxy.on('proxyRequest', onRequest);
httpsProxy.on('proxyResponse', onResponse);
httpProxy.enableHttpsProxy(httpsProxy);
});