@chenshunyu/proxy 1.0.0-beta.30 → 1.0.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.npmigore ADDED
@@ -0,0 +1,3 @@
1
+ *.env.*
2
+ node_modules
3
+ package-lock.json
package/README.md CHANGED
@@ -27,7 +27,7 @@ key2: value2
27
27
  1. Open the browser developer tools (usually by pressing F12 or right-clicking and selecting "Inspect").
28
28
  1. Go to the "Network" tab.
29
29
  1. Right-click any request and select "Copy" -> "Copy request headers".<br>
30
- ![help](help.png)
30
+ ![help](https://cdn.jsdelivr.net/gh/ccddnn/pub@main/help.png)
31
31
  1. Paste the copied content into a text file and save it as `headers.txt`.
32
32
 
33
33
  ### Request Expiration
package/index.js CHANGED
@@ -103,11 +103,23 @@ function start(server) {
103
103
  function watch() {
104
104
  console.log('Watching...')
105
105
  watching = true
106
- fs.watch(filePath, e => {
106
+ fs.watch(filePath, debounce(e => {
107
107
  if (e === 'change') {
108
108
  console.log('File changes, reload...');
109
109
  close?.()
110
110
  read();
111
111
  }
112
- });
112
+ }, 200));
113
+ }
114
+
115
+ function debounce(func, wait) {
116
+ let timeout;
117
+ return function executedFunction(...args) {
118
+ const later = () => {
119
+ clearTimeout(timeout);
120
+ func(...args);
121
+ };
122
+ clearTimeout(timeout);
123
+ timeout = setTimeout(later, wait);
124
+ };
113
125
  }
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "name": "@chenshunyu/proxy",
3
- "version": "1.0.0-beta.30",
4
- "publishConfig": {
5
- "access": "public"
6
- },
7
- "description": "",
8
- "main": "index.js",
9
- "bin": {
10
- "proxy": "index.js"
11
- },
12
- "scripts": {
13
- "test": "node index.js --port 8080 --file headers.env.txt"
14
- },
15
- "author": "",
16
- "license": "ISC",
17
- "dependencies": {
18
- "http-proxy": "^1.18.1"
19
- }
20
- }
1
+ {
2
+ "name": "@chenshunyu/proxy",
3
+ "version": "1.0.0-beta.40",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "",
8
+ "main": "index.js",
9
+ "bin": {
10
+ "proxy": "index.js"
11
+ },
12
+ "scripts": {
13
+ "test": "node index.js --port 8080 --file headers.env.txt"
14
+ },
15
+ "author": "chenshunyu",
16
+ "license": "ISC",
17
+ "dependencies": {
18
+ "http-proxy": "^1"
19
+ }
20
+ }
@@ -1 +1 @@
1
- start "publish" npm publish --registry=https://registry.npmjs.org
1
+ start "publish" npm --registry=https://registry.npmjs.org publish
package/headers.env.txt DELETED
@@ -1,15 +0,0 @@
1
- POST /post HTTP/1.1
2
- Accept-Encoding: gzip, deflate, br, zstd
3
- Accept-Language: en-US,en;q=0.9
4
- Connection: keep-alive
5
- Content-Length: 0
6
- Host: httpbin.org
7
- Referer: https://httpbin.org/
8
- Sec-Fetch-Dest: empty
9
- Sec-Fetch-Mode: cors
10
- Sec-Fetch-Site: same-origin
11
- User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
12
- accept: application/json
13
- sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"
14
- sec-ch-ua-mobile: ?0
15
- sec-ch-ua-platform: "Windows"
package/publish.bat DELETED
@@ -1 +0,0 @@
1
- start "publish" npm publish