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.
This commit is contained in:
arsam
2026-09-18 23:17:10 +03:30
parent fc620081a8
commit e6e1515d37
+34
View File
@@ -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",
},
});
}