修復 too many connection 問題
This commit is contained in:
37
app/api/competitions/[id]/route.ts
Normal file
37
app/api/competitions/[id]/route.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
// =====================================================
|
||||
// 獲取競賽詳情 API
|
||||
// =====================================================
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { CompetitionService } from '@/lib/services/database-service';
|
||||
|
||||
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
|
||||
// 獲取競賽詳情
|
||||
const competition = await CompetitionService.getCompetitionById(id);
|
||||
|
||||
if (!competition) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '競賽不存在',
|
||||
error: '找不到指定的競賽'
|
||||
}, { status: 404 });
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '競賽詳情獲取成功',
|
||||
data: competition
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('獲取競賽詳情失敗:', error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '獲取競賽詳情失敗',
|
||||
error: error instanceof Error ? error.message : '未知錯誤'
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user