From 5b6313f16f508882a0ea67716b7dbaa1c6967f04 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 30 Jun 2025 08:28:13 +0000 Subject: (대표님) 20250630 16시 - 유저 도메인별 라우터 분리와 보안성검토 대응 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/menu-assignments/active-status/route.ts | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/api/menu-assignments/active-status/route.ts (limited to 'app/api/menu-assignments') diff --git a/app/api/menu-assignments/active-status/route.ts b/app/api/menu-assignments/active-status/route.ts new file mode 100644 index 00000000..bd31e6b8 --- /dev/null +++ b/app/api/menu-assignments/active-status/route.ts @@ -0,0 +1,32 @@ +// app/api/menu-assignments/active-status/route.ts + +import { NextResponse } from "next/server" +import db from "@/db/db" +import { menuAssignments } from "@/db/schema" +import { eq } from "drizzle-orm" + +export async function GET() { + try { + // 모든 메뉴의 활성 상태를 조회 + const menus = await db + .select({ + menuPath: menuAssignments.menuPath, + isActive: menuAssignments.isActive, + }) + .from(menuAssignments) + + // 객체 형태로 변환 { "/evcp/menu-path": true, "/evcp/other-path": false } + const activeMenusMap = menus.reduce((acc, menu) => { + acc[menu.menuPath] = menu.isActive + return acc + }, {} as Record) + + return NextResponse.json(activeMenusMap) + } catch (error) { + console.error("Error fetching menu active status:", error) + return NextResponse.json( + { error: "Failed to fetch menu status" }, + { status: 500 } + ) + } +} \ No newline at end of file -- cgit v1.2.3