locadot 1.2.4 โ 1.2.6
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/README.md +9 -5
- package/dist/lib/locadot-file.js +2 -1
- package/dist/server.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ npx locadot --host dev.localhost --port 3350
|
|
|
22
22
|
## ๐ฆ Commands
|
|
23
23
|
|
|
24
24
|
##### โถ๏ธ Default (Run Proxy)
|
|
25
|
+
|
|
25
26
|
###### Starts a reverse proxy to the specified localhost port.
|
|
26
27
|
|
|
27
28
|
```bash
|
|
@@ -29,29 +30,31 @@ npx locadot --host <custom.localhost> --port <localhost-port>
|
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
##### ๐งพ View Registered Hosts
|
|
32
|
-
###### Displays all domains currently registered with locadot.
|
|
33
33
|
|
|
34
|
+
###### Displays all domains currently registered with locadot.
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
37
|
npx locadot host
|
|
37
38
|
```
|
|
39
|
+
|
|
38
40
|
##### ๐บ Watch Logs
|
|
39
|
-
###### Continuously watches and outputs proxy logs in real time.
|
|
40
41
|
|
|
42
|
+
###### Continuously watches and outputs proxy logs in real time.
|
|
41
43
|
|
|
42
44
|
```bash
|
|
43
45
|
npx locadot log
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
##### ๐งน Clear Logs
|
|
47
|
-
###### Clears all saved logs.
|
|
48
49
|
|
|
50
|
+
###### Clears all saved logs.
|
|
49
51
|
|
|
50
52
|
```bash
|
|
51
53
|
npx locadot clear logs
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
##### ๐ Restart Proxy
|
|
57
|
+
|
|
55
58
|
###### Restarts the proxy server and reloads configuration.
|
|
56
59
|
|
|
57
60
|
```bash
|
|
@@ -59,18 +62,19 @@ npx locadot restart
|
|
|
59
62
|
```
|
|
60
63
|
|
|
61
64
|
##### ๐ Stop All
|
|
62
|
-
###### Stops all running locadot hosts and shuts down the proxy server.
|
|
63
65
|
|
|
66
|
+
###### Stops all running locadot hosts and shuts down the proxy server.
|
|
64
67
|
|
|
65
68
|
```bash
|
|
66
69
|
npx locadot stop
|
|
67
70
|
```
|
|
68
|
-
---
|
|
69
71
|
|
|
72
|
+
---
|
|
70
73
|
|
|
71
74
|
### ๐ Contributing:
|
|
72
75
|
|
|
73
76
|
Pull requests are welcome! Feel free to open issues for bugs or feature requests. Contributions help improve locadot for everyone, so don't hesitate to get involved.
|
|
74
77
|
|
|
75
78
|
---
|
|
79
|
+
|
|
76
80
|
##### Made with โค๏ธ to make secure local development simple.
|
package/dist/lib/locadot-file.js
CHANGED
|
@@ -48,10 +48,11 @@ class locadotFile {
|
|
|
48
48
|
delete registry[domain];
|
|
49
49
|
fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
|
|
50
50
|
}
|
|
51
|
-
static async watchRegistry() {
|
|
51
|
+
static async watchRegistry(callBackOnChange) {
|
|
52
52
|
return fs_1.default.watch(constants_1.locadotPath.REGISTRY_FILE, async (eventType) => {
|
|
53
53
|
if (eventType === "change") {
|
|
54
54
|
this.updateLogs("๐ Updated domain mappings.");
|
|
55
|
+
callBackOnChange && callBackOnChange();
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
}
|
package/dist/server.js
CHANGED
|
@@ -18,11 +18,15 @@ class ProxyHandler {
|
|
|
18
18
|
let domainMap = await locadot_file_1.default.getRegistry();
|
|
19
19
|
const proxy = http_proxy_1.default.createProxyServer({});
|
|
20
20
|
const defaultCert = await (0, certs_1.createSSL)("localhost");
|
|
21
|
-
const watcher = await locadot_file_1.default.watchRegistry()
|
|
21
|
+
const watcher = await locadot_file_1.default.watchRegistry(async () => {
|
|
22
|
+
locadot_file_1.default.updateLogs("๐ Updated domain mappings.");
|
|
23
|
+
domainMap = await locadot_file_1.default.getRegistry();
|
|
24
|
+
});
|
|
22
25
|
process.on("SIGINT", async () => await locadot_file_1.default.destroy(watcher));
|
|
23
26
|
process.on("SIGTERM", async () => await locadot_file_1.default.destroy(watcher));
|
|
24
27
|
const requestHandler = (req, res) => {
|
|
25
28
|
const host = req.headers.host?.split(":")[0];
|
|
29
|
+
locadot_file_1.default.updateLogs(host || "", "log");
|
|
26
30
|
const targetPort = domainMap[host];
|
|
27
31
|
if (!targetPort) {
|
|
28
32
|
res.writeHead(502, { "Content-Type": "text/html" });
|
|
@@ -73,7 +77,6 @@ class ProxyHandler {
|
|
|
73
77
|
await this.startProxy();
|
|
74
78
|
}
|
|
75
79
|
let registry = await locadot_file_1.default.getRegistry();
|
|
76
|
-
console.log(registry);
|
|
77
80
|
if (!fs_1.default.existsSync(constants_1.locadotPath.REGISTRY_FILE)) {
|
|
78
81
|
fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, "{}");
|
|
79
82
|
}
|
package/package.json
CHANGED