- app/music/layout.tsx: isServiceVisible/notFound 제거, metadata 유지 - lib/service-visibility.ts: HideableService type에서 'music' 제거 (gyeol|lotto만 유지) - app/api/admin/services/route.ts: DEFAULT_SERVICES에서 music 행 제거 /music* 라우트가 이제 공개(static) 상태로 노출됨. service_settings music DELETE는 Task 1 마이그레이션이 담당. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { createAdminClient } from '@/lib/supabase/admin';
|
|
import { verifyAdminTokenNode } from '@/lib/admin-auth';
|
|
import { cookies } from 'next/headers';
|
|
|
|
export const runtime = 'nodejs';
|
|
|
|
async function checkAuth() {
|
|
const cookieStore = await cookies();
|
|
const token = cookieStore.get('admin_token')?.value;
|
|
return token && verifyAdminTokenNode(token);
|
|
}
|
|
|
|
export async function GET() {
|
|
if (!(await checkAuth())) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
const supabase = createAdminClient();
|
|
|
|
const { data, error } = await supabase
|
|
.from('service_settings')
|
|
.select('*')
|
|
.order('order_index');
|
|
|
|
if (error) {
|
|
// 테이블이 없으면 기본값 반환
|
|
return NextResponse.json({ services: DEFAULT_SERVICES });
|
|
}
|
|
|
|
return NextResponse.json({ services: data?.length ? data : DEFAULT_SERVICES });
|
|
}
|
|
|
|
export async function PATCH(request: Request) {
|
|
if (!(await checkAuth())) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
const { id, is_active } = await request.json();
|
|
const supabase = createAdminClient();
|
|
|
|
const { error } = await supabase
|
|
.from('service_settings')
|
|
.upsert({ id, is_active, updated_at: new Date().toISOString() });
|
|
|
|
if (error) {
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
}
|
|
|
|
return NextResponse.json({ success: true });
|
|
}
|
|
|
|
const DEFAULT_SERVICES = [
|
|
{ id: 'gyeol', name: 'CONTOUR 설문', description: '/gyeol PMF 설문', is_active: false, order_index: 103 },
|
|
{ id: 'lotto', name: '로또 추천', description: '로또 번호 추천 노출', is_active: false, order_index: 105 },
|
|
];
|