locadot 1.2.7 → 1.3.1
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 +16 -2
- package/dist/core.js +3 -0
- package/dist/index.js +10 -2
- package/dist/lib/commands.js +9 -0
- package/dist/lib/locadot-file.js +1 -0
- package/dist/server.js +12 -5
- package/dist/utils/constants.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## ✨ Features
|
|
4
4
|
|
|
5
5
|
- ✅ Automatically generates trusted local SSL certificates
|
|
6
|
-
- 🔁 Reverse proxies `https://your.custom.domain
|
|
6
|
+
- 🔁 Reverse proxies `localhost:PORT ` → `https://your.custom.domain.localhost`
|
|
7
7
|
- 🖥️ Works on Windows, macOS, and Linux
|
|
8
8
|
- 🛠️ OS-specific guidance for host setup
|
|
9
9
|
- ⚠️ Warns and exits if domain isn’t correctly mapped to a local IP
|
|
@@ -42,7 +42,7 @@ npx locadot host
|
|
|
42
42
|
###### Continuously watches and outputs proxy logs in real time.
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
npx locadot
|
|
45
|
+
npx locadot watch logs
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
##### 🧹 Clear Logs
|
|
@@ -52,7 +52,13 @@ npx locadot log
|
|
|
52
52
|
```bash
|
|
53
53
|
npx locadot clear logs
|
|
54
54
|
```
|
|
55
|
+
##### 🧹 Show Logs Path
|
|
55
56
|
|
|
57
|
+
###### Print the path of logged files used.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx locadot path logs
|
|
61
|
+
```
|
|
56
62
|
##### 🔄 Restart Proxy
|
|
57
63
|
|
|
58
64
|
###### Restarts the proxy server and reloads configuration.
|
|
@@ -69,6 +75,14 @@ npx locadot restart
|
|
|
69
75
|
npx locadot stop
|
|
70
76
|
```
|
|
71
77
|
|
|
78
|
+
##### 🛑 Kill
|
|
79
|
+
|
|
80
|
+
###### Stops all running locadot hosts, clear logs and host mapping and shuts down the proxy server.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx locadot kill
|
|
84
|
+
```
|
|
85
|
+
|
|
72
86
|
---
|
|
73
87
|
|
|
74
88
|
### 🙌 Contributing:
|
package/dist/core.js
CHANGED
|
@@ -3,8 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const locadot_file_1 = __importDefault(require("./lib/locadot-file"));
|
|
6
7
|
const server_1 = __importDefault(require("./server"));
|
|
7
8
|
async function run() {
|
|
9
|
+
locadot_file_1.default.updateLogs("🔄 Starting central proxy.");
|
|
8
10
|
await server_1.default.startCentralProxy();
|
|
11
|
+
locadot_file_1.default.updateLogs("☑️ Central proxy started.");
|
|
9
12
|
}
|
|
10
13
|
run();
|
package/dist/index.js
CHANGED
|
@@ -32,19 +32,27 @@ async function run() {
|
|
|
32
32
|
.command("host", "Show all hosts.", () => {
|
|
33
33
|
commands_1.default.getRegistry();
|
|
34
34
|
})
|
|
35
|
-
.command("
|
|
35
|
+
.command("watch logs", "Watch log files", () => { }, async (argv) => {
|
|
36
36
|
commands_1.default.watchLogs();
|
|
37
37
|
})
|
|
38
38
|
.command("clear logs", "Clear logs", () => { }, async (argv) => {
|
|
39
39
|
commands_1.default.clearLogs();
|
|
40
|
+
})
|
|
41
|
+
.command("path logs", "Show log path", () => { }, async (argv) => {
|
|
42
|
+
commands_1.default.logPath();
|
|
40
43
|
})
|
|
41
44
|
.command("restart", "Restart locadot", () => { }, async (argv) => {
|
|
42
45
|
commands_1.default.restart();
|
|
43
46
|
})
|
|
44
|
-
.command("stop", "Stop
|
|
47
|
+
.command("stop", "Stop central proxy and logs.", () => { }, async (argv) => {
|
|
45
48
|
await commands_1.default.stop();
|
|
46
49
|
console.log(constants_1.errorConstants.proxyClose);
|
|
47
50
|
process.exit(0);
|
|
51
|
+
})
|
|
52
|
+
.command("kill", "Stop central proxy and clear all logs and also port mapping.", () => { }, async (argv) => {
|
|
53
|
+
await commands_1.default.kill();
|
|
54
|
+
console.log(constants_1.errorConstants.proxyClose);
|
|
55
|
+
process.exit(0);
|
|
48
56
|
})
|
|
49
57
|
.help().argv;
|
|
50
58
|
}
|
package/dist/lib/commands.js
CHANGED
|
@@ -27,6 +27,12 @@ class Commands {
|
|
|
27
27
|
}
|
|
28
28
|
catch (error) { }
|
|
29
29
|
}
|
|
30
|
+
static async kill() {
|
|
31
|
+
try {
|
|
32
|
+
await server_1.default.killProxy();
|
|
33
|
+
}
|
|
34
|
+
catch (error) { }
|
|
35
|
+
}
|
|
30
36
|
static async restart() {
|
|
31
37
|
await server_1.default.restartProxy();
|
|
32
38
|
console.log("☑️ Proxy successfully restarted.");
|
|
@@ -53,5 +59,8 @@ class Commands {
|
|
|
53
59
|
}
|
|
54
60
|
catch (error) { }
|
|
55
61
|
}
|
|
62
|
+
static async logPath() {
|
|
63
|
+
console.log(constants_1.locadotPath.LOGS);
|
|
64
|
+
}
|
|
56
65
|
}
|
|
57
66
|
exports.default = Commands;
|
package/dist/lib/locadot-file.js
CHANGED
package/dist/server.js
CHANGED
|
@@ -22,19 +22,23 @@ class ProxyHandler {
|
|
|
22
22
|
locadot_file_1.default.updateLogs("🔄 Updated domain mappings.");
|
|
23
23
|
domainMap = await locadot_file_1.default.getRegistry();
|
|
24
24
|
});
|
|
25
|
-
process.on("SIGINT", async () =>
|
|
26
|
-
|
|
25
|
+
process.on("SIGINT", async () => {
|
|
26
|
+
locadot_file_1.default.updateLogs("🛑 Proxy stopped.", "error", "Proxy soft destroyed as process SIGINT");
|
|
27
|
+
await locadot_file_1.default.softDestroy(watcher);
|
|
28
|
+
});
|
|
29
|
+
process.on("SIGTERM", async () => {
|
|
30
|
+
locadot_file_1.default.updateLogs("🛑 Proxy stopped.", "error", "Proxy soft destroyed as process SIGTERM");
|
|
31
|
+
await locadot_file_1.default.softDestroy(watcher);
|
|
32
|
+
});
|
|
27
33
|
const requestHandler = (req, res) => {
|
|
28
34
|
const host = req.headers.host?.split(":")[0];
|
|
29
|
-
locadot_file_1.default.updateLogs(host || "", "log");
|
|
30
35
|
const targetPort = domainMap[host];
|
|
31
36
|
if (!targetPort) {
|
|
32
37
|
res.writeHead(502, { "Content-Type": "text/html" });
|
|
33
38
|
res.end((0, utils_1.proxyNotFound)(host));
|
|
34
|
-
locadot_file_1.default.updateLogs(host || "", "warn", "Proxy not exist.");
|
|
35
39
|
}
|
|
36
40
|
proxy.web(req, res, { target: `http://localhost:${targetPort}` }, (err) => {
|
|
37
|
-
locadot_file_1.default.updateLogs(host || "", "warn",
|
|
41
|
+
locadot_file_1.default.updateLogs(host || "", "warn", `${err.name}=> ${err.message}`);
|
|
38
42
|
res.writeHead(502);
|
|
39
43
|
res.end("Connection failed. Host not found.");
|
|
40
44
|
});
|
|
@@ -92,6 +96,9 @@ class ProxyHandler {
|
|
|
92
96
|
console.log(`✅ ${domain} => http://localhost:${port}`);
|
|
93
97
|
}
|
|
94
98
|
async stopProxy() {
|
|
99
|
+
await locadot_file_1.default.softDestroy();
|
|
100
|
+
}
|
|
101
|
+
async killProxy() {
|
|
95
102
|
await locadot_file_1.default.destroy();
|
|
96
103
|
}
|
|
97
104
|
async restartProxy() {
|
package/dist/utils/constants.js
CHANGED
|
@@ -19,4 +19,5 @@ exports.errorConstants = {
|
|
|
19
19
|
invalidHost: "❌ Invalid domain. Please use a valid localhost domain like dev.localhost, localhost, test.localhost, etc.",
|
|
20
20
|
hostExist: "❌ Domain already in use. Please choose another domain or stop the existing instance.",
|
|
21
21
|
proxyClose: "☑️ Successfully stopped all locadot instances.",
|
|
22
|
+
softClose: "☑️ Successfully stopped central proxy..",
|
|
22
23
|
};
|
package/package.json
CHANGED