import { NextRequest, NextResponse } from "next/server"; import { generateCrosswordLayout } from "@/lib/arcade/crosswordEngine"; import type { CrosswordSize } from "@/types/arcade"; import { getArcadePack } from "@/services/arcadeService"; const CROSSWORD_SIZES = new Set(["mini", "standard", "large", "extra-large"]); export async function GET( request: NextRequest, context: { params: Promise<{ id: string }> } ) { const { id } = await context.params; const sizeValue = request.nextUrl.searchParams.get("size") ?? "standard"; if (!CROSSWORD_SIZES.has(sizeValue as CrosswordSize)) { return NextResponse.json({ error: "A valid Crossword size is required." }, { status: 400 }); } const pack = await getArcadePack(id); if (!pack || pack.gameType !== "crossword" || pack.normalized.type !== "crossword") { return NextResponse.json({ error: "Crossword pack not found" }, { status: 404 }); } const size = sizeValue as CrosswordSize; return NextResponse.json(generateCrosswordLayout(pack.normalized, size, `crossword-hub-preview-v1:${id}:${size}`)); }