about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/index.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/index.ts b/src/index.ts
index 27af7a7..030b0bd 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -66,14 +66,17 @@ function walkDirectory(root: string, dir: string) {
 
 walkDirectory(publicDir, "");
 
-async function serveFile(file: File | undefined): Promise<Response> {
+async function serveFile(
+  file: File | undefined,
+  statusCode: number = 200,
+): Promise<Response> {
   if (file && (await fsp.exists(file.filename))) {
     return new Response(Bun.file(file.filename), {
       headers: file.headers,
-      status: 200,
+      status: statusCode,
     });
   } else {
-    return serveFile(files.get("/404.html"));
+    return serveFile(files.get("/404.html"), 404);
   }
 }