import { NextResponse } from 'next/server'; import { createComponentLogger, getSafeErrorDetails } from '@/lib/logger' const healthLogger = createComponentLogger('health-api') export async function GET() { try { // Basic health check const healthData = { status: 'ok', timestamp: new Date().toISOString(), uptime: process.uptime(), version: process.env.npm_package_version || '1.0.0', // Git SHA injected at build time by deploy.sh (Dockerfile ARG) — identifies // the running build; null in local dev where no deploy stamp exists. deployVersion: process.env.DEPLOY_VERSION || null, environment: process.env.NODE_ENV || 'development', }; return NextResponse.json(healthData, { status: 200, headers: { 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', }, }); } catch (error) { healthLogger.error('Health check failed', getSafeErrorDetails(error)) return NextResponse.json( { status: 'error', timestamp: new Date().toISOString(), message: 'Health check failed', }, { status: 503 } ); } } // Also support HEAD requests for lighter health checks export async function HEAD() { return new Response(null, { status: 200, headers: { 'Cache-Control': 'no-cache, no-store, must-revalidate', }, }); }