import { NextResponse } from "next/server"; // The community board — "Thank you Senator BAM". // GET -> the last 200 posts, newest first. // POST -> { nick, message } (nickname only, no account — by design). // // Public by nature; the controls live in lib/board.js (rate limit per IP, // content caps, markup stripping, URL-only rejection). export const dynamic = "force-dynamic"; export async function GET() { try { const { getBoard, boardCount } = await import("../../../lib/board"); const [posts, count] = await Promise.all([getBoard(), boardCount()]); return NextResponse.json({ ok: true, posts, count }); } catch (e) { return NextResponse.json({ ok: false, error: "board unavailable" }, { status: 500 }); } } export async function POST(req) { let body; try { body = await req.json(); } catch { return NextResponse.json({ ok: false, error: "expected json" }, { status: 400 }); } try { const { postBoard } = await import("../../../lib/board"); const r = await postBoard(req, body); return NextResponse.json(r, { status: r.ok ? 200 : r.status }); } catch (e) { console.warn("[bama] board post failed:", String((e && e.message) || e).slice(0, 160)); return NextResponse.json({ ok: false, error: "could not post right now" }, { status: 500 }); } }