Refactor server stuff

This commit is contained in:
Schluffe
2026-09-18 11:41:18 +02:00
parent f062753f8f
commit 1c6f2368a1
9 changed files with 169 additions and 120 deletions
+15
View File
@@ -0,0 +1,15 @@
/// <reference lib="deno.ns" />
export function startServer(
handler: Deno.ServeHandler,
hostname: string = "localhost",
port: number = 8042,
): () => Promise<void> {
const ac = new AbortController();
const server = Deno.serve({ hostname, port, signal: ac.signal }, handler);
return () => {
ac.abort();
return server.finished;
};
}