Initial commit

This commit is contained in:
2025-06-22 00:01:22 +03:00
parent fd70166cf6
commit 033b80bfad
153 changed files with 26874 additions and 1 deletions

45
app/api/test-db/route.ts Normal file
View File

@@ -0,0 +1,45 @@
import { NextResponse } from "next/server"
import { testConnection, executeQuery, getPoolStats, healthCheck } from "@/lib/database"
export async function GET() {
try {
// Test basic connection
const connectionTest = await testConnection()
if (!connectionTest) {
return NextResponse.json(
{
error: "Database connection failed",
details: "Could not connect to MySQL database",
},
{ status: 500 },
)
}
// Test query execution with automatic connection management
const result = await executeQuery("SELECT COUNT(*) as user_count FROM users")
// Get pool statistics
const poolStats = getPoolStats()
// Get comprehensive health check
const health = await healthCheck()
return NextResponse.json({
success: true,
message: "Database connection successful",
userCount: (result as any)[0].user_count,
poolStats,
health,
timestamp: new Date().toISOString(),
})
} catch (error) {
console.error("Database test error:", error)
return NextResponse.json(
{
error: "Database test failed",
details: error instanceof Error ? error.message : "Unknown error",
},
{ status: 500 },
)
}
}