Files
ra-h-os/app/api/health/route.ts
T
“BeeRad”andClaude Opus 4.6 3b04a1bad0 fix: move API keys to .env.local, remove localStorage dual system
Single source of truth: OPENAI_API_KEY in .env.local. Deleted the
apiKeyService class/singleton that stored keys in localStorage.
All server code reads process.env directly. FirstRunModal and
Settings now show .env.local instructions instead of key input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 11:46:41 +11:00

39 lines
1.1 KiB
TypeScript

/**
* Main health check endpoint
* Returns overall system health status for quick verification
*/
import { NextResponse } from 'next/server';
import { checkDatabaseHealth } from '@/services/database';
import { hasValidOpenAiKey } from '@/services/storage/apiKeys';
export const runtime = 'nodejs';
export async function GET() {
try {
const dbHealth = await checkDatabaseHealth();
const response = {
status: dbHealth.connected ? 'ok' : 'degraded',
database: dbHealth.connected ? 'connected' : 'disconnected',
vectorSearch: dbHealth.vectorExtension ? 'enabled' : 'disabled',
aiFeatures: hasValidOpenAiKey() ? 'enabled' : 'disabled (no API key)',
timestamp: new Date().toISOString(),
};
return NextResponse.json(response, {
status: dbHealth.connected ? 200 : 503,
});
} catch (error) {
return NextResponse.json(
{
status: 'error',
database: 'error',
error: error instanceof Error ? error.message : 'Unknown error',
timestamp: new Date().toISOString(),
},
{ status: 500 }
);
}
}