diff options
Diffstat (limited to 'packages/integrations/deno/src/server.ts')
-rw-r--r-- | packages/integrations/deno/src/server.ts | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/packages/integrations/deno/src/server.ts b/packages/integrations/deno/src/server.ts index 94dce59ce..49da3f270 100644 --- a/packages/integrations/deno/src/server.ts +++ b/packages/integrations/deno/src/server.ts @@ -2,13 +2,18 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; +// @ts-ignore +import { Server } from 'https://deno.land/std@0.167.0/http/server.ts'; +// @ts-ignore +import { fetch } from 'https://deno.land/x/file_fetch/mod.ts'; + + interface Options { port?: number; hostname?: string; start?: boolean; } -// @ts-ignore let _server: Server | undefined = undefined; let _startPromise: Promise<void> | undefined = undefined; @@ -36,18 +41,7 @@ export function start(manifest: SSRManifest, options: Options) { // try to fetch a static file instead const url = new URL(request.url); const localPath = new URL('./' + app.removeBase(url.pathname), clientRoot); - const stringLocalPath = localPath.toString(); - // @ts-ignore - const extendName = fileExtension(stringLocalPath); - const fileResp = await fetch( - !extendName - ? `${ - stringLocalPath.endsWith('/') - ? `${stringLocalPath}index.html` - : `${stringLocalPath}/index.html` - }` - : stringLocalPath - ); + const fileResp = await fetch(localPath.toString()); // If the static file can't be found if (fileResp.status == 404) { @@ -68,7 +62,6 @@ export function start(manifest: SSRManifest, options: Options) { }; const port = options.port ?? 8085; - // @ts-ignore _server = new Server({ port, hostname: options.hostname ?? '0.0.0.0', |