diff --git a/.vscode/launch.json b/.vscode/launch.json index e3abcfed..8a59dcba 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,6 +19,24 @@ "--allow-all" ], "attachSimplePort": 9229 + }, + { + "name": "citations-supabase-deno", + "request": "launch", + "type": "node", + "program": "server.tsx", + "cwd": "/home/d9k/cr/demo/citations-supabase-demo", + "runtimeExecutable": "${env:HOME}/.deno/bin/deno", + "runtimeArgs": [ + "run", + "--no-npm", + "--inspect", + "--allow-all", + "--no-check", + // "--watch" + ], + "args": [], + "attachSimplePort": 9229 } ] } diff --git a/lib/middleware/compiler.ts b/lib/middleware/compiler.ts index 79e2bb55..5a246a75 100644 --- a/lib/middleware/compiler.ts +++ b/lib/middleware/compiler.ts @@ -26,7 +26,20 @@ export const compiler = (options: CompilerOptions) => { const path = !isRemoteSource ? join(root, pathname) : pathname; const url = !isRemoteSource ? toFileUrl(path) : new URL(pathname); - const isCompilerTarget = [".ts", ".tsx", ".js", ".jsx"].includes(extension); + const isCompilerTarget = [".ts", ".tsx", ".js", ".jsx", ".json"].includes(extension); + const isJson = [".json"].includes(extension); + + if (method === "GET" && isJson) { + const bytes = await fetch(url).then((response) => response.arrayBuffer()); + const source = new TextDecoder().decode(bytes); + + return new Response(source, { + status: 200, + headers: { + "content-type": "application/json; charset=utf-8", + }, + }); + } if (method === "GET" && isCompilerTarget) { const bytes = await fetch(url).then((response) => response.arrayBuffer());