aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-06 06:14:04 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-06 06:14:04 -0700
commit69653729f0a8e0dd2efcb7ff48e061c9b541c051 (patch)
tree7bc3aedbb8703ca0155991bb1fb73a6b09d0b158
parent81eb47de0eb08081ed0677b71aa47e9a2b473cab (diff)
downloadbun-69653729f0a8e0dd2efcb7ff48e061c9b541c051.tar.gz
bun-69653729f0a8e0dd2efcb7ff48e061c9b541c051.tar.zst
bun-69653729f0a8e0dd2efcb7ff48e061c9b541c051.zip
tweak examples
-rw-r--r--examples/cat.ts5
-rw-r--r--examples/http-file.ts4
-rw-r--r--examples/http.ts1
3 files changed, 4 insertions, 6 deletions
diff --git a/examples/cat.ts b/examples/cat.ts
index 1bb1c809a..a7d60b347 100644
--- a/examples/cat.ts
+++ b/examples/cat.ts
@@ -1,5 +1,6 @@
import { resolve } from "path";
const { write, stdout, file } = Bun;
-const input = resolve(process.argv[process.argv.length - 1]);
+const { argv } = process;
-await write(stdout, file(input));
+const path = resolve(argv.at(-1));
+await write(stdout, file(path));
diff --git a/examples/http-file.ts b/examples/http-file.ts
index f2c0773e8..3c1d67169 100644
--- a/examples/http-file.ts
+++ b/examples/http-file.ts
@@ -1,9 +1,7 @@
// Start a fast HTTP server from a function
Bun.serve({
fetch(req) {
- const url = new URL(req.url.substring(1), "file://" + import.meta.path);
- const path = Bun.resolveSync(url.pathname, import.meta.path);
- return new Response(Bun.file(path));
+ return new Response("Hello World!");
},
// this is called when fetch() throws or rejects
diff --git a/examples/http.ts b/examples/http.ts
index 4d58f270f..4f52af2a6 100644
--- a/examples/http.ts
+++ b/examples/http.ts
@@ -19,7 +19,6 @@ Bun.serve({
// keyFile: './key.pem',
port: 8080, // number or string
- hostname: "localhost", // defaults to 0.0.0.0
});
// Start a fast HTTP server from the main file's export