Files
infohliadka/pages/api/health.ts

17 lines
534 B
TypeScript

import type { NextApiRequest, NextApiResponse } from "next"
import { getHealthStatus } from "../../lib/monitoring"
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "GET") return res.status(405).json({ error: "Method not allowed" })
try {
const health = getHealthStatus()
res.status(200).json(health)
} catch (error) {
res.status(500).json({
status: 'unhealthy',
error: 'Health check failed',
timestamp: new Date().toISOString()
})
}
}