Files
OmniRoute/src/lib/serverLifecycle.ts
Ravi Tharuma 916ccddfd8 fix: add native lifecycle-aware health endpoint (#7852)
* fix: add native health endpoint

* fix: keep health endpoint dynamic

---------

Co-authored-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
2026-07-20 15:55:48 -03:00

24 lines
645 B
TypeScript

export type ServerLifecyclePhase = "starting" | "ready" | "stopping";
declare global {
var __omnirouteServerLifecycle: ServerLifecyclePhase | undefined;
}
export function getServerLifecyclePhase(): ServerLifecyclePhase {
return globalThis.__omnirouteServerLifecycle ?? "starting";
}
export function markServerStarting(): void {
globalThis.__omnirouteServerLifecycle = "starting";
}
export function markServerReady(): void {
if (getServerLifecyclePhase() !== "stopping") {
globalThis.__omnirouteServerLifecycle = "ready";
}
}
export function markServerStopping(): void {
globalThis.__omnirouteServerLifecycle = "stopping";
}