feat(parcel-sync): eTerra health check + maintenance detection

- New eterra-health.ts service: pings eTerra periodically (3min),
  detects maintenance (503, keywords), tracks consecutive failures
- New /api/eterra/health endpoint for explicit health queries
- Session route blocks login when eTerra is in maintenance (503 response)
- GET /api/eterra/session now includes eterraAvailable/eterraMaintenance
- ConnectionPill shows amber 'Mentenanță' state with AlertTriangle icon
  instead of confusing red error when eTerra is down
- Auto-connect skips when maintenance detected, retries when back online
- 30s session poll auto-detects recovery and re-enables auto-connect
This commit is contained in:
AI Assistant
2026-03-08 10:28:30 +02:00
parent 6557cd5374
commit b7a236c45a
5 changed files with 362 additions and 27 deletions
+27
View File
@@ -0,0 +1,27 @@
/**
* GET /api/eterra/health — eTerra platform availability check.
*
* Returns health status without requiring authentication.
* Triggers a fresh check if cached result is stale.
*
* POST /api/eterra/health — force an immediate fresh check.
*/
import { NextResponse } from "next/server";
import {
getEterraHealth,
checkEterraHealthNow,
} from "@/modules/parcel-sync/services/eterra-health";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function GET() {
const health = getEterraHealth();
return NextResponse.json(health);
}
export async function POST() {
const health = await checkEterraHealthNow();
return NextResponse.json(health);
}