cg / hackerproducts

63 files · 5,740 lines · 159.1 KB — Next.js 15, React 19, TypeScript, PostgreSQL, Object Storage, plain CSS.

Quick jump: page.tsx / page.tsx / globals.css / schema.sql / package.json

root / src / app / api / preview / route.ts

src/app/api/preview/route.ts · 15 lines · 522 B← back to folder
1import { NextResponse } from "next/server";
2import { getCurrentUser } from "@/lib/auth";
3import { renderMarkdown } from "@/lib/markdown";
4
5export 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
cg / hackerproducts — hacker products