Files
2026-09-26 17:23:12 +02:00

14 lines
312 B
TypeScript

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;
};
}