"use client"; /** * HTTP 요청 액션 노드 * REST API를 호출하는 노드 */ import { memo } from "react"; import { Handle, Position, NodeProps } from "reactflow"; import { Globe, Lock, Unlock } from "lucide-react"; import type { HttpRequestActionNodeData } from "@/types/node-editor"; // HTTP 메서드별 색상 const METHOD_COLORS: Record = { GET: { bg: "bg-green-100", text: "text-green-700" }, POST: { bg: "bg-blue-100", text: "text-blue-700" }, PUT: { bg: "bg-orange-100", text: "text-orange-700" }, PATCH: { bg: "bg-yellow-100", text: "text-yellow-700" }, DELETE: { bg: "bg-red-100", text: "text-red-700" }, HEAD: { bg: "bg-gray-100", text: "text-gray-700" }, OPTIONS: { bg: "bg-purple-100", text: "text-purple-700" }, }; export const HttpRequestActionNode = memo(({ data, selected }: NodeProps) => { const methodColor = METHOD_COLORS[data.method] || METHOD_COLORS.GET; const hasUrl = data.url && data.url.trim().length > 0; const hasAuth = data.authentication?.type && data.authentication.type !== "none"; // URL에서 도메인 추출 const getDomain = (url: string) => { try { const urlObj = new URL(url); return urlObj.hostname; } catch { return url; } }; return (
{/* 입력 핸들 */} {/* 헤더 */}
{data.displayName || "HTTP 요청"}
{/* 본문 */}
{/* 메서드 & 인증 */}
{data.method} {hasAuth ? ( {data.authentication?.type} ) : ( 인증없음 )}
{/* URL */}
URL: {hasUrl ? ( {getDomain(data.url)} ) : ( URL 설정 필요 )}
{/* 바디 타입 */} {data.bodyType && data.bodyType !== "none" && (
Body: {data.bodyType.toUpperCase()}
)} {/* 타임아웃 & 재시도 */}
{data.options?.timeout && ( 타임아웃: {Math.round(data.options.timeout / 1000)}초 )} {data.options?.retryCount && data.options.retryCount > 0 && ( 재시도: {data.options.retryCount}회 )}
{/* 출력 핸들 */}
); }); HttpRequestActionNode.displayName = "HttpRequestActionNode";