29 lines
805 B
TypeScript
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 })
|
|
}
|
|
}
|