feat: enable dir listing and show dot files in deno code

This commit is contained in:
Huakun Shen 2025-01-29 11:38:49 -05:00
parent d2a05753b3
commit 796640961e
No known key found for this signature in database
3 changed files with 9 additions and 7 deletions

View File

@ -4,10 +4,12 @@ import type { API } from '../src/api.types.ts';
expose({ expose({
serve: (path: string, port: number): Promise<number> => { serve: (path: string, port: number): Promise<number> => {
// const port2 = port ?? findFreePort();
const server = Deno.serve({ port }, (req: Request) => { const server = Deno.serve({ port }, (req: Request) => {
return serveDir(req, { return serveDir(req, {
fsRoot: path fsRoot: path,
showDirListing: true,
showDotfiles: true,
quiet: true
}); });
}); });
console.error('Server started at port', path, server.addr.port); console.error('Server started at port', path, server.addr.port);

View File

@ -6,7 +6,7 @@
// let isDragging = false; // let isDragging = false;
let { onSubmit }: { onSubmit: (path: string, port: number) => void } = $props(); let { onSubmit }: { onSubmit: (path: string, port: number) => void } = $props();
let path = $state(''); let path = $state('');
let port = $state(0); let port = $state(8000);
onMount(() => { onMount(() => {
// event.onDragEnter(() => { // event.onDragEnter(() => {

View File

@ -23,7 +23,7 @@
} }
getRpcAPI() getRpcAPI()
.then((rpc) => { .then((rpc) =>
rpc.api.serve(path, port).then((realPort) => { rpc.api.serve(path, port).then((realPort) => {
jobsStore.addJob({ jobsStore.addJob({
path, path,
@ -31,11 +31,11 @@
process: rpc.process process: rpc.process
}); });
toast.success('Server started'); toast.success('Server started');
}); })
}) )
.catch((err) => { .catch((err) => {
toast.error('Failed to serve', { toast.error('Failed to serve', {
description: err.message description: `${err.message}; consider changing the port`
}); });
}); });
} }