46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
// =====================================================
|
|
// 調試競賽 API
|
|
// =====================================================
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { CompetitionService } from '@/lib/services/database-service';
|
|
|
|
// 獲取所有競賽和當前競賽狀態
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
// 獲取所有競賽
|
|
const allCompetitions = await CompetitionService.getAllCompetitions();
|
|
|
|
// 獲取當前競賽
|
|
const currentCompetition = await CompetitionService.getCurrentCompetition();
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
data: {
|
|
allCompetitions: allCompetitions.map(c => ({
|
|
id: c.id,
|
|
name: c.name,
|
|
status: c.status,
|
|
is_current: c.is_current,
|
|
is_active: c.is_active
|
|
})),
|
|
currentCompetition: currentCompetition ? {
|
|
id: currentCompetition.id,
|
|
name: currentCompetition.name,
|
|
status: currentCompetition.status,
|
|
is_current: currentCompetition.is_current,
|
|
is_active: currentCompetition.is_active
|
|
} : null
|
|
}
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('調試競賽失敗:', error);
|
|
return NextResponse.json({
|
|
success: false,
|
|
message: '調試競賽失敗',
|
|
error: error instanceof Error ? error.message : '未知錯誤'
|
|
}, { status: 500 });
|
|
}
|
|
}
|