From 26de528a96a79754dc71003c7b677b6a9b2838ef Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:16:53 +0330 Subject: [PATCH] Import source: vault/app/api/share/[id]/route Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- vault/app/api/share/[id]/route.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 vault/app/api/share/[id]/route.ts diff --git a/vault/app/api/share/[id]/route.ts b/vault/app/api/share/[id]/route.ts new file mode 100644 index 0000000..128c7d6 --- /dev/null +++ b/vault/app/api/share/[id]/route.ts @@ -0,0 +1,27 @@ +import { NextResponse } from "next/server"; +import { jsonError, purgeExpiredSnippets, publicSnippet } 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((candidate) => candidate.id === id); + if (!snippet) return jsonError("Snippet not found", 404); + + if (snippet.privacy === "password") { + return NextResponse.json({ + locked: true, + snippet: { + ...publicSnippet(snippet), + code: "", + }, + }); + } + + return NextResponse.json({ locked: false, snippet: publicSnippet(snippet) }); +}