From 7366c18692a944f3e70aaa6a6b11e9c4d09e364f Mon Sep 17 00:00:00 2001 From: gahusb Date: Thu, 2 Jul 2026 14:25:05 +0900 Subject: [PATCH] =?UTF-8?q?chore(phase0):=20=EA=B3=A0=EC=95=84=20API=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=E2=80=94=20track/[token](=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=A7=81=EC=A0=91=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EB=A1=9C=20=EB=8C=80=EC=B2=B4=EB=90=A8)=C2=B7saju/lotto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - app/api/track/[token]: 페이지에서 Supabase 직접 조회로 대체됨 - app/api/saju/lotto: 프론트 fetch 0회, 외부 saju-engine 전용 참조: Task 6 (Phase 0 cleanup) Co-Authored-By: Claude Opus 4.8 (1M context) --- app/api/saju/lotto/route.ts | 41 ---------------------------------- app/api/track/[token]/route.ts | 31 ------------------------- 2 files changed, 72 deletions(-) delete mode 100644 app/api/saju/lotto/route.ts delete mode 100644 app/api/track/[token]/route.ts diff --git a/app/api/saju/lotto/route.ts b/app/api/saju/lotto/route.ts deleted file mode 100644 index 9cf933e..0000000 --- a/app/api/saju/lotto/route.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { NextRequest, NextResponse } from 'next/server'; - -const SAJU_ENGINE_URL = process.env.SAJU_ENGINE_URL; -const SAJU_ENGINE_SECRET = process.env.SAJU_ENGINE_SECRET; - -export async function POST(request: NextRequest) { - if (!SAJU_ENGINE_URL) { - return NextResponse.json({ error: '사주 엔진 URL이 설정되지 않았습니다' }, { status: 503 }); - } - - try { - const body = await request.json(); - - const response = await fetch(`${SAJU_ENGINE_URL}/saju/lotto`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - ...(SAJU_ENGINE_SECRET ? { 'X-API-Secret': SAJU_ENGINE_SECRET } : {}), - }, - body: JSON.stringify(body), - signal: AbortSignal.timeout(15000), - }); - - const data = await response.json(); - - if (!response.ok) { - return NextResponse.json( - { error: data.detail || '로또 번호 생성 실패' }, - { status: response.status } - ); - } - - return NextResponse.json(data); - } catch (error: unknown) { - if (error instanceof Error && error.name === 'TimeoutError') { - return NextResponse.json({ error: '사주 엔진 응답 시간 초과' }, { status: 504 }); - } - console.error('로또 번호 생성 프록시 오류:', error); - return NextResponse.json({ error: '서버 오류' }, { status: 500 }); - } -} diff --git a/app/api/track/[token]/route.ts b/app/api/track/[token]/route.ts deleted file mode 100644 index fa30a86..0000000 --- a/app/api/track/[token]/route.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NextResponse } from 'next/server'; -import { createAdminClient } from '@/lib/supabase/admin'; - -export const runtime = 'nodejs'; - -// 비회원 의뢰 추적 API — 향후 클라이언트 측 폴링/갱신용. -// PII(이메일·전화·메시지 본문)는 select에서 제외한다. -// DB 예외(마이그레이션 미적용 42703 포함)는 모두 404로 폴백한다. -export async function GET(_req: Request, { params }: { params: Promise<{ token: string }> }) { - const { token } = await params; - if (!token || token.length > 64) return NextResponse.json({ error: 'not found' }, { status: 404 }); - - const admin = createAdminClient(); - const { data: request, error } = await admin - .from('contact_requests') - .select('id, name, service, status, project_type, budget, timeline, created_at, updated_at') - .eq('public_token', token) - .maybeSingle(); - if (error || !request) return NextResponse.json({ error: 'not found' }, { status: 404 }); - - const { data: quote } = await admin - .from('quotes') - .select('public_token, title, status, valid_until') - .eq('contact_request_id', request.id) - .in('status', ['sent', 'accepted', 'rejected']) - .order('created_at', { ascending: false }) - .limit(1) - .maybeSingle(); - - return NextResponse.json({ request, quote: quote ?? null }); -}