Used to gauge health of service.
Ideally, an administration page can show us the uptime of our services and any major errors or warnings.
For example: In a service with a long startup time, they can broadcast a warning status, saying they are not fully "up" yet
GET /api/health
The endpoint shall:`
[x] return 200 went requested
[x] Return { status: STATUS, message: MESSAGE, last_updated: TIME } in body
Status types include
[x] ok
[x] warn
[x] err
message in ok status can be ignored but should be provided anyways, even if empty string
It might be a good idea to add a type somewhere
interface HealthResponse {
status: "ok" | "warn" | "err";
message: string;
last_updated: <some time type or string>
}
I'd also recommend adding an exported function called updateHealth(status, message), which will update the status message, as well as set the last updated time.
Used to gauge health of service. Ideally, an administration page can show us the uptime of our services and any major errors or warnings. For example: In a service with a long startup time, they can broadcast a warning status, saying they are not fully "up" yet
The endpoint shall:`
{ status: STATUS, message: MESSAGE, last_updated: TIME }
in bodyStatus types include
ok
warn
err
message in
ok
status can be ignored but should be provided anyways, even if empty stringIt might be a good idea to add a type somewhere
I'd also recommend adding an exported function called
updateHealth(status, message)
, which will update the status message, as well as set the last updated time.