mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
tweak examples
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user