// app/api/projects/code-to-id/route.ts import { NextRequest, NextResponse } from "next/server" import { getProjectIdByCode } from "@/lib/swp/project-utils" /** * 프로젝트 코드로 프로젝트 ID 조회 * * GET /api/projects/code-to-id?code=PROJ_CODE */ export async function GET(request: NextRequest) { try { const { searchParams } = new URL(request.url) const code = searchParams.get("code") if (!code) { return NextResponse.json( { success: false, message: "프로젝트 코드(code)가 필요합니다" }, { status: 400 } ) } const projectId = await getProjectIdByCode(code) if (!projectId) { return NextResponse.json( { success: false, message: "프로젝트를 찾을 수 없습니다" }, { status: 404 } ) } return NextResponse.json({ success: true, projectId, }) } catch (error) { console.error("❌ 프로젝트 ID 조회 오류:", error) return NextResponse.json( { success: false, message: error instanceof Error ? error.message : "조회 중 오류 발생" }, { status: 500 } ) } }