performance optimizations and database indexing

This commit is contained in:
2025-07-28 11:33:17 +02:00
parent 597659a148
commit 558172f2be
2 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import type { NextApiRequest, NextApiResponse } from "next"
import { optimizeDatabase, getDatabaseStats } from "../../../lib/db-optimizations"
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "POST") {
try {
await optimizeDatabase()
res.json({
success: true,
message: "Database optimized successfully",
optimized_at: new Date().toISOString()
})
} catch (error) {
console.error('Optimization error:', error)
res.status(500).json({ error: "Optimization failed" })
}
} else if (req.method === "GET") {
try {
const stats = await getDatabaseStats()
res.json(stats)
} catch (error) {
console.error('Stats error:', error)
res.status(500).json({ error: "Failed to get database stats" })
}
} else {
res.status(405).json({ error: "Method not allowed" })
}
}