klg-asutk-app/app/api/health/route.ts
Yuriy 0150aba4f5 Consolidation: KLG ASUTK + PAPA integration
- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites)
- Remove localhost refs: openapi, inbox page
- Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI
- Add stub routes: knowledge/insights, recommendations, search, log-error
- Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests
- Fix inbox-server: ORDER BY created_at, package.json
- Remove redundant app/api/inbox/files route (rewrites handle it)
- knowledge/ in gitignore (large PDFs)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 17:18:31 +03:00

38 lines
1.4 KiB
TypeScript

export const dynamic = "force-dynamic";
import { NextRequest, NextResponse } from 'next/server';
import { checkHealth } from '@/lib/monitoring/health';
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const readiness = searchParams.get('readiness') === 'true';
const health = await checkHealth();
// Для readiness probe проверяем, что система готова принимать трафик
if (readiness) {
// Readiness означает, что система может обрабатывать запросы
// Проверяем, что хотя бы основные компоненты работают
const isReady =
health.status === 'healthy' ||
(health.status === 'degraded' &&
health.checks.database.status === 'ok'); // БД должна быть доступна
if (!isReady) {
return NextResponse.json(
{
status: 'not ready',
message: 'System is not ready to accept traffic',
checks: health.checks,
},
{ status: 503 }
);
}
}
// Для liveness probe возвращаем общий статус
const statusCode = health.status === 'healthy' ? 200 :
health.status === 'degraded' ? 200 : 503;
return NextResponse.json(health, { status: statusCode });
}