diff options
author | 2022-04-07 06:08:48 -0700 | |
---|---|---|
committer | 2022-04-07 06:08:48 -0700 | |
commit | b97e81b27faf3d8805a8670035298d910cd32a83 (patch) | |
tree | 361f2a70077a5bc4a328cbaa48ff38b63f821c6b /examples/http.ts | |
parent | e08cc968cb531e35aa93e45c3443bc8d16854b83 (diff) | |
download | bun-b97e81b27faf3d8805a8670035298d910cd32a83.tar.gz bun-b97e81b27faf3d8805a8670035298d910cd32a83.tar.zst bun-b97e81b27faf3d8805a8670035298d910cd32a83.zip |
More types
Diffstat (limited to 'examples/http.ts')
-rw-r--r-- | examples/http.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/http.ts b/examples/http.ts index 4f52af2a6..3a44f421e 100644 --- a/examples/http.ts +++ b/examples/http.ts @@ -1,16 +1,17 @@ // Start a fast HTTP server from a function Bun.serve({ - fetch(req) { - return new Response("Hello World!"); + async fetch(req: Request) { + return new Response(`Echo: ${req.url}`); }, + // baseURI: "http://localhost:3000", + // this is called when fetch() throws or rejects - error(err: Error) { - return new Response("uh oh! :(" + err.toString(), { status: 500 }); - }, + // error(err: Error) { + // return new Response("uh oh! :(\n" + err.toString(), { status: 500 }); + // }, - // this boolean enables the bun's default error handler - // sometime after the initial release, it will auto reload as well + // this boolean enables bun's default error handler development: process.env.NODE_ENV !== "production", // note: this isn't node, but for compatibility bun supports process.env + more stuff in process @@ -18,7 +19,7 @@ Bun.serve({ // certFile: './cert.pem', // keyFile: './key.pem', - port: 8080, // number or string + port: 3000, // number or string }); // Start a fast HTTP server from the main file's export |