clean error handling

This commit is contained in:
marlonerler
2024-07-04 18:02:53 +02:00
parent 9649e3e522
commit 57d484a0e6
-5
View File
@@ -6,7 +6,6 @@ import { ServerWebSocket } from "bun";
// CONFIG
const staticDir = "static/dist";
const defaultPage = "index.html";
const errorPage = "404.html";
// TYPES
export type WS = ServerWebSocket<unknown>;
@@ -19,16 +18,12 @@ const server = Bun.serve({
// respond
const requestPath = new URL(request.url).pathname;
try {
switch (requestPath) {
case "/":
return createFileResponse(defaultPage);
default:
return createFileResponse(requestPath);
}
} catch {
return createFileResponse(errorPage);
}
},
websocket: {