blob: bd31e6b8c3eee95cc1375bef0d83053ff86cba28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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<string, boolean>)
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 }
)
}
}
|