From e6e1515d37943c15d3ec4417c1d13d32b0d567f8 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:17:10 +0330 Subject: [PATCH] Import source: vault/app/raw/[id]/route Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- vault/app/raw/[id]/route.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 vault/app/raw/[id]/route.ts diff --git a/vault/app/raw/[id]/route.ts b/vault/app/raw/[id]/route.ts new file mode 100644 index 0000000..8da5c8f --- /dev/null +++ b/vault/app/raw/[id]/route.ts @@ -0,0 +1,34 @@ +import { purgeExpiredSnippets } from "@/lib/server-api"; +import { readDb } from "@/lib/server-db"; + +interface RouteContext { + params: Promise<{ id: string }>; +} + +export async function GET(_request: Request, context: RouteContext) { + await purgeExpiredSnippets(); + const { id } = await context.params; + const db = await readDb(); + const snippet = db.snippets.find((s) => s.id === id); + + if (!snippet) { + return new Response("404 Not Found\n", { + status: 404, + headers: { "Content-Type": "text/plain; charset=utf-8" }, + }); + } + + if (snippet.privacy === "password") { + return new Response("403 Forbidden: This snippet is password-protected.\n", { + status: 403, + headers: { "Content-Type": "text/plain; charset=utf-8" }, + }); + } + + return new Response(snippet.code, { + headers: { + "Content-Type": "text/plain; charset=utf-8", + "Cache-Control": "no-store", + }, + }); +}