cg / hackerproducts
63 files · 5,740 lines · 159.1 KB — Next.js 15, React 19, TypeScript, PostgreSQL, Object Storage, plain CSS.
Quick jump: page.tsxpage.tsxglobals.cssschema.sqlpackage.json
root / src / app / api / preview / route.ts
src/app/api/preview/route.ts · 15 lines · 522 B← back to folder
| 1 | import { NextResponse } from "next/server"; |
| 2 | import { getCurrentUser } from "@/lib/auth"; |
| 3 | import { renderMarkdown } from "@/lib/markdown"; |
| 4 | |
| 5 | export async function POST(request: Request) { |
| 6 | const user = await getCurrentUser(); |
| 7 | if (!user) { |
| 8 | return NextResponse.json({ error: "Sign in required." }, { status: 401 }); |
| 9 | } |
| 10 | |
| 11 | const body = (await request.json().catch(() => ({}))) as { markdown?: string }; |
| 12 | const html = await renderMarkdown((body.markdown ?? "").slice(0, 50000)); |
| 13 | return NextResponse.json({ html }); |
| 14 | } |
| 15 |