@rubriclab/bunl 0.0.4 → 0.0.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/build/{client.js → client.mjs} +18 -19
- package/package.json +2 -2
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// client.ts
|
|
2
|
-
import {parseArgs} from "util";
|
|
3
|
-
async function main({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}) {
|
|
8
|
-
const serverUrl = `ws://${domain || "localhost:1234"}?new${subdomain ? `&subdomain=${subdomain}` : ""}`;
|
|
2
|
+
import { parseArgs } from "util";
|
|
3
|
+
async function main({ url, domain, subdomain }) {
|
|
4
|
+
const serverUrl = `ws://${domain || "localhost:1234"}?new${
|
|
5
|
+
subdomain ? `&subdomain=${subdomain}` : ""
|
|
6
|
+
}`;
|
|
9
7
|
const socket = new WebSocket(serverUrl);
|
|
10
8
|
socket.addEventListener("message", (event) => {
|
|
11
9
|
const data = JSON.parse(event.data);
|
|
@@ -13,10 +11,12 @@ async function main({
|
|
|
13
11
|
if (data.method) {
|
|
14
12
|
fetch(`${url}${data.path}`, {
|
|
15
13
|
method: data.method,
|
|
16
|
-
headers: data.headers
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
headers: data.headers,
|
|
15
|
+
})
|
|
16
|
+
.then((res) => res.text())
|
|
17
|
+
.then((res) => {
|
|
18
|
+
socket.send(res);
|
|
19
|
+
});
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
socket.addEventListener("open", (event) => {
|
|
@@ -30,23 +30,22 @@ var { values } = parseArgs({
|
|
|
30
30
|
port: {
|
|
31
31
|
type: "string",
|
|
32
32
|
required: true,
|
|
33
|
-
short: "p"
|
|
33
|
+
short: "p",
|
|
34
34
|
},
|
|
35
35
|
domain: {
|
|
36
36
|
type: "string",
|
|
37
|
-
short: "d"
|
|
37
|
+
short: "d",
|
|
38
38
|
},
|
|
39
39
|
subdomain: {
|
|
40
40
|
type: "string",
|
|
41
|
-
short: "s"
|
|
42
|
-
}
|
|
41
|
+
short: "s",
|
|
42
|
+
},
|
|
43
43
|
},
|
|
44
|
-
allowPositionals: true
|
|
44
|
+
allowPositionals: true,
|
|
45
45
|
});
|
|
46
|
-
if (!values.port)
|
|
47
|
-
throw "pass --port 3000";
|
|
46
|
+
if (!values.port) throw "pass --port 3000";
|
|
48
47
|
main({
|
|
49
48
|
url: `localhost:${values.port}`,
|
|
50
49
|
domain: values.domain,
|
|
51
|
-
subdomain: values.subdomain
|
|
50
|
+
subdomain: values.subdomain,
|
|
52
51
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bin": {
|
|
3
|
-
"bunl": "./build/client.js"
|
|
3
|
+
"bunl": "bun run ./build/client.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "@rubriclab/bunl",
|
|
6
6
|
"description": "expose localhost to the world",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.6",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|