Files
msgapp/src/app/api/boards/route.ts

32 lines
840 B
TypeScript
Raw Normal View History

2025-10-09 11:23:27 +09:00
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
2025-11-10 21:58:36 +09:00
const where: any = { status: "active" };
if (category) {
if (category.length === 25 || category.length === 24) {
where.categoryId = category;
} else {
where.category = { slug: category };
}
}
2025-10-09 11:23:27 +09:00
const boards = await prisma.board.findMany({
where,
2025-10-09 11:23:27 +09:00
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 } },
2025-10-09 11:23:27 +09:00
},
});
return NextResponse.json({ boards });
}