feat: 로또 추천 API, 텔레그램 봇 연동, 관리자 페이지 추가
- 로또 번호 추천 구독자 전용 페이지 (/services/lotto/recommend) - NAS 몬테카를로 API 연동 + 클라이언트 사이드 폴백 - 무료 미리보기 1개 + 구독자용 프리미엄 번호 추천 - 구독 플랜 변경: 골드(900원)/플래티넘(2,900원)/다이아(9,900원) - 텔레그램 봇 연동: 연결/해제, 웹훅, /start 명령 처리 - 마이페이지 텔레그램 연결 UI + 가이드 모달 - 관리자 페이지 (/admin): 대시보드, 회원, 서비스, 문의 관리 - Supabase 마이그레이션: profiles 텔레그램 컬럼, 신규 상품 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
47
app/api/lotto/preview/route.ts
Normal file
47
app/api/lotto/preview/route.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
/**
|
||||
* GET /api/lotto/preview
|
||||
* 인증 없이 NAS /api/lotto/recommend 단일 호출 (맛보기용 무료 추천)
|
||||
* NAS 미연결 시 → { error: 'NAS_UNAVAILABLE' } 503 반환
|
||||
* 클라이언트에서 이 경우 자체 Monte Carlo 폴백 처리
|
||||
*/
|
||||
export async function GET() {
|
||||
const base = process.env.NAS_LOTTO_API_URL;
|
||||
|
||||
if (!base) {
|
||||
return NextResponse.json({ error: 'NAS_UNAVAILABLE' }, { status: 503 });
|
||||
}
|
||||
|
||||
try {
|
||||
const headers: Record<string, string> = {};
|
||||
if (process.env.NAS_LOTTO_API_KEY) {
|
||||
headers['Authorization'] = `Bearer ${process.env.NAS_LOTTO_API_KEY}`;
|
||||
}
|
||||
|
||||
const res = await fetch(`${base}/api/lotto/recommend`, {
|
||||
method: 'GET',
|
||||
headers,
|
||||
signal: AbortSignal.timeout(8000),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
console.warn(`[lotto/preview] NAS returned ${res.status}`);
|
||||
return NextResponse.json({ error: 'NAS_UNAVAILABLE' }, { status: 503 });
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
source: 'nas',
|
||||
numbers: data.numbers ?? [],
|
||||
metrics: data.metrics ?? null,
|
||||
});
|
||||
} catch (err: unknown) {
|
||||
// ECONNREFUSED, 타임아웃 등 — 클라이언트 폴백 신호
|
||||
const e = err as { name?: string; code?: string; message?: string };
|
||||
console.warn('[lotto/preview] NAS unreachable:', e?.code ?? e?.message ?? e?.name);
|
||||
return NextResponse.json({ error: 'NAS_UNAVAILABLE' }, { status: 503 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user