2026-02-14 10:30:27 +01:00
|
|
|
/**
|
|
|
|
|
* Health check endpoint — reports app and Immich connectivity status.
|
|
|
|
|
* Used by Docker HEALTHCHECK, monitoring tools, and load balancers.
|
|
|
|
|
*
|
|
|
|
|
* GET /api/health → { status, immich, uptime }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
|
import { immich } from '@/lib/immich';
|
|
|
|
|
|
|
|
|
|
const startTime = Date.now();
|
|
|
|
|
|
|
|
|
|
export async function GET() {
|
2026-02-14 11:47:26 +01:00
|
|
|
const immichOk = await immich.ping();
|
2026-02-14 10:30:27 +01:00
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
const body = {
|
|
|
|
|
status: immichOk ? 'ok' : 'degraded',
|
|
|
|
|
immich: immichOk ? 'connected' : 'unreachable',
|
|
|
|
|
uptime: Math.floor((Date.now() - startTime) / 1000),
|
|
|
|
|
};
|
2026-02-14 10:30:27 +01:00
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
return NextResponse.json(body, {
|
|
|
|
|
status: immichOk ? 200 : 503,
|
|
|
|
|
headers: { 'Cache-Control': 'no-store' },
|
|
|
|
|
});
|
2026-02-14 10:30:27 +01:00
|
|
|
}
|