Skip to content

Commit 09ee671

Browse files
committed
switch off using default modules
1 parent a343946 commit 09ee671

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ type definitions are now included in this project, no extra steps required.
2222
This example will modify any search results coming from google and replace all the result titles with "Pwned!".
2323

2424
```javascript
25-
var Proxy = require('http-mitm-proxy');
26-
var proxy = Proxy();
25+
const Proxy = require('http-mitm-proxy').Proxy;
26+
// or using import/module (package.json -> "type": "module")
27+
// import { Proxy } from "http-mitm-proxy";
28+
const proxy = new Proxy();
2729

2830
proxy.onError(function(ctx, err) {
2931
console.error('proxy error:', err);
@@ -35,13 +37,14 @@ proxy.onRequest(function(ctx, callback) {
3537
ctx.use(Proxy.gunzip);
3638

3739
ctx.onResponseData(function(ctx, chunk, callback) {
38-
chunk = new Buffer(chunk.toString().replace(/<h3.*?<\/h3>/g, '<h3>Pwned!</h3>'));
40+
chunk = Buffer.from(chunk.toString().replace(/<h3.*?<\/h3>/g, '<h3>Pwned!</h3>'));
3941
return callback(null, chunk);
4042
});
4143
}
4244
return callback();
4345
});
4446

47+
console.log('begin listening on 8081')
4548
proxy.listen({port: 8081});
4649
```
4750

bin/mitm-proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { hideBin } from "yargs/helpers";
44

55
import d from "debug";
66
const debug = d("http-mitm-proxy:bin");
7-
import Proxy from "../lib/proxy";
7+
import { Proxy } from "../lib/proxy";
88
const proxy = new Proxy();
99

1010
const args = yargs(hideBin(process.argv))

index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import proxy from './lib/proxy'
2-
3-
export default proxy;
1+
export { Proxy } from './lib/proxy'

lib/proxy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,4 +1441,3 @@ export class Proxy implements IProxy {
14411441
return headers;
14421442
}
14431443
}
1444-
export default Proxy;

0 commit comments

Comments
 (0)