tweak examples

This commit is contained in:
Jarred Sumner
2022-04-06 06:14:04 -07:00
parent 81eb47de0e
commit 69653729f0
3 changed files with 4 additions and 6 deletions

View File

@@ -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));

View File

@@ -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

View File

@@ -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