diff --git a/.vscode/settings.json b/.vscode/settings.json index 6f4c05388..22ae4cf98 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "deno.enable": true, "deno.lint": true, + "deno.unstable": true, "editor.formatOnSave": true, "editor.defaultFormatter": "denoland.vscode-deno" } diff --git a/src-deno/server.ts b/src-deno/server.ts index babf11ade..e9d7e2066 100644 --- a/src-deno/server.ts +++ b/src-deno/server.ts @@ -2,6 +2,7 @@ import { Hono } from "./deps.ts"; import { serveStatic } from "./deps.ts"; import configureRedirects from "./redirects.ts"; +const kv = await Deno.openKv(); const app = new Hono(); // Configure redirects @@ -12,7 +13,14 @@ app.use("*", serveStatic({ root: "./" })); // 404s app.notFound(async (c) => { - console.error("404 error returned for path: ", c.req.path); + try { + await kv.set(["404s", c.req.path], c.req.path); + } catch (e) { + console.error(e); + } finally { + console.error("404 error returned for path: ", c.req.path); + } + const f = await Deno.readTextFile("./404.html"); c.status(404); return c.html(f);