From 796640961ec3577297f475a75a0084c9343bbb41 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Wed, 29 Jan 2025 11:38:49 -0500 Subject: [PATCH] feat: enable dir listing and show dot files in deno code --- deno-src/index.ts | 6 ++++-- src/lib/components/SelectForm.svelte | 2 +- src/routes/+page.svelte | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/deno-src/index.ts b/deno-src/index.ts index 2a7427c..8ef9368 100644 --- a/deno-src/index.ts +++ b/deno-src/index.ts @@ -4,10 +4,12 @@ import type { API } from '../src/api.types.ts'; expose({ serve: (path: string, port: number): Promise => { - // const port2 = port ?? findFreePort(); const server = Deno.serve({ port }, (req: Request) => { return serveDir(req, { - fsRoot: path + fsRoot: path, + showDirListing: true, + showDotfiles: true, + quiet: true }); }); console.error('Server started at port', path, server.addr.port); diff --git a/src/lib/components/SelectForm.svelte b/src/lib/components/SelectForm.svelte index f6b5da9..8af65b7 100644 --- a/src/lib/components/SelectForm.svelte +++ b/src/lib/components/SelectForm.svelte @@ -6,7 +6,7 @@ // let isDragging = false; let { onSubmit }: { onSubmit: (path: string, port: number) => void } = $props(); let path = $state(''); - let port = $state(0); + let port = $state(8000); onMount(() => { // event.onDragEnter(() => { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ff4cd47..dad0a4f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -23,7 +23,7 @@ } getRpcAPI() - .then((rpc) => { + .then((rpc) => rpc.api.serve(path, port).then((realPort) => { jobsStore.addJob({ path, @@ -31,11 +31,11 @@ process: rpc.process }); toast.success('Server started'); - }); - }) + }) + ) .catch((err) => { toast.error('Failed to serve', { - description: err.message + description: `${err.message}; consider changing the port` }); }); }