/** * πŸ§ͺ ν…ŒμŠ€νŠΈ μ „μš© λ²„νŠΌ λ°μ΄ν„°ν”Œλ‘œμš° 라우트 (인증 μ—†μŒ) * * 개발 ν™˜κ²½μ—μ„œλ§Œ μ‚¬μš©λ˜λŠ” ν…ŒμŠ€νŠΈμš© API μ—”λ“œν¬μΈνŠΈ */ import express from "express"; import { getButtonDataflowConfig, updateButtonDataflowConfig, getAvailableDiagrams, getDiagramRelationships, getRelationshipPreview, executeOptimizedButton, executeSimpleDataflow, getJobStatus, } from "../controllers/buttonDataflowController"; import { AuthenticatedRequest } from "../types/auth"; import config from "../config/environment"; const router = express.Router(); // 🚨 개발 ν™˜κ²½μ—μ„œλ§Œ ν™œμ„±ν™” if (config.nodeEnv !== "production") { // ν…ŒμŠ€νŠΈμš© μ‚¬μš©μž 정보 μ„€μ • 미듀웨어 const setTestUser = (req: AuthenticatedRequest, res: any, next: any) => { req.user = { userId: "test-user", userName: "Test User", companyCode: "*", email: "test@example.com", }; next(); }; // λͺ¨λ“  λΌμš°νŠΈμ— ν…ŒμŠ€νŠΈ μ‚¬μš©μž μ„€μ • router.use(setTestUser); // ============================================================================ // πŸ§ͺ ν…ŒμŠ€νŠΈ μ „μš© API μ—”λ“œν¬μΈνŠΈλ“€ // ============================================================================ // λ²„νŠΌλ³„ μ œμ–΄κ΄€λ¦¬ μ„€μ • 쑰회 router.get("/config/:buttonId", getButtonDataflowConfig); // λ²„νŠΌλ³„ μ œμ–΄κ΄€λ¦¬ μ„€μ • μ—…λ°μ΄νŠΈ router.put("/config/:buttonId", updateButtonDataflowConfig); // μ‚¬μš© κ°€λŠ₯ν•œ 관계도 λͺ©λ‘ 쑰회 router.get("/diagrams", getAvailableDiagrams); // νŠΉμ • κ΄€κ³„λ„μ˜ 관계 λͺ©λ‘ 쑰회 router.get("/diagrams/:diagramId/relationships", getDiagramRelationships); // 관계 미리보기 정보 쑰회 router.get( "/diagrams/:diagramId/relationships/:relationshipId/preview", getRelationshipPreview ); // μ΅œμ ν™”λœ λ²„νŠΌ μ‹€ν–‰ (μ¦‰μ‹œ 응닡 + λ°±κ·ΈλΌμš΄λ“œ) router.post("/execute-optimized", executeOptimizedButton); // κ°„λ‹¨ν•œ λ°μ΄ν„°ν”Œλ‘œμš° μ¦‰μ‹œ μ‹€ν–‰ router.post("/execute-simple", executeSimpleDataflow); // λ°±κ·ΈλΌμš΄λ“œ μž‘μ—… μƒνƒœ 쑰회 router.get("/job-status/:jobId", getJobStatus); // ν…ŒμŠ€νŠΈ μƒνƒœ 확인 μ—”λ“œν¬μΈνŠΈ router.get("/test-status", (req: AuthenticatedRequest, res) => { res.json({ success: true, message: "ν…ŒμŠ€νŠΈ λͺ¨λ“œ ν™œμ„±ν™”λ¨", user: req.user, environment: config.nodeEnv, }); }); } else { // 운영 ν™˜κ²½μ—μ„œλŠ” μ ‘κ·Ό 차단 router.use((req, res) => { res.status(403).json({ success: false, message: "ν…ŒμŠ€νŠΈ APIλŠ” 개발 ν™˜κ²½μ—μ„œλ§Œ μ‚¬μš© κ°€λŠ₯ν•©λ‹ˆλ‹€.", }); }); } export default router;