Files
ExecuBoard/app/api/database/test/route.ts
2025-08-01 00:55:05 +08:00

29 lines
805 B
TypeScript

import { NextResponse } from 'next/server'
import { testConnection } from '@/lib/database'
// GET - 測試資料庫連接
export async function GET() {
try {
const isConnected = await testConnection()
if (isConnected) {
return NextResponse.json({
status: 'success',
message: '資料庫連接正常',
timestamp: new Date().toISOString()
})
} else {
return NextResponse.json({
status: 'error',
message: '資料庫連接失敗'
}, { status: 500 })
}
} catch (error) {
console.error('資料庫測試失敗:', error)
return NextResponse.json({
status: 'error',
message: '資料庫測試失敗',
error: error instanceof Error ? error.message : '未知錯誤'
}, { status: 500 })
}
}