@rubriclab/bunl 0.0.13 → 0.0.14

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/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ PORT=1234
2
+ SCHEME=https
3
+ DOMAIN=example.so
package/client.ts CHANGED
@@ -21,14 +21,17 @@ async function main({
21
21
 
22
22
  socket.addEventListener("message", async (event) => {
23
23
  const data = JSON.parse(event.data as string);
24
- console.log("message:", data);
25
24
 
26
- if (open && data.url) browser(data.url);
25
+ if (data.url) {
26
+ console.log(`\n\n↪ Your URL: \x1b[32m${data.url}\x1b[0m\n`);
27
+ if (open) browser(data.url);
28
+ }
27
29
 
28
30
  if (data.method) {
29
31
  const res = await fetch(`${url}${data.pathname}`, {
30
32
  method: data.method,
31
33
  headers: data.headers,
34
+ body: data.body,
32
35
  });
33
36
 
34
37
  const { status, statusText, headers } = res;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "name": "@rubriclab/bunl",
6
6
  "description": "Expose localhost to the world",
7
- "version": "0.0.13",
7
+ "version": "0.0.14",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
package/server.ts CHANGED
@@ -34,8 +34,11 @@ serve<Client>({
34
34
  // The magic: forward the req to the client
35
35
  const client = clients.get(subdomain)!;
36
36
  const { method, url, headers: reqHeaders } = req;
37
+ const reqBody = await req.text();
37
38
  const { pathname } = new URL(url);
38
- client.send(JSON.stringify({ method, pathname, headers: reqHeaders }));
39
+ client.send(
40
+ JSON.stringify({ method, pathname, body: reqBody, headers: reqHeaders })
41
+ );
39
42
 
40
43
  // Wait for the client to cache its response above
41
44
  await sleep(1);