Files
msgapp/src/app/api/boards/route.ts
koreacomp5 c5bc8f5b49
All checks were successful
deploy-on-main / deploy (push) Successful in 26s
check
2025-11-10 21:58:36 +09:00

32 lines
840 B
TypeScript

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 });
}