import { NextResponse } from "next/server"; import prisma from "@/lib/prisma"; export async function GET(req: Request) { const { searchParams } = new URL(req.url); const category = searchParams.get("category"); // slug or id const where: any = { status: "active" }; if (category) { if (category.length === 25 || category.length === 24) { where.categoryId = category; } else { where.category = { slug: category }; } } const boards = await prisma.board.findMany({ where, orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }], select: { id: true, name: true, slug: true, description: true, allowAnonymousPost: true, isAdultOnly: true, category: { select: { id: true, name: true, slug: true } }, }, }); return NextResponse.json({ boards }); }