@firebreak/vitals 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -258,10 +258,34 @@ When a `token` is configured, the endpoint serves two tiers from a single route:
258
258
  | No token provided | **Shallow** — `200` with `{ status: "ok", timestamp, ...metadata }` |
259
259
  | Valid token provided | **Deep** — `200`/`503` with full check results + metadata |
260
260
  | Invalid token provided | `403 Forbidden` |
261
- | No token configured | Deep response always (backwards-compatible) |
261
+ | No token configured | **Shallow** by default (see `deep` option below) |
262
262
 
263
263
  The shallow response lets load balancers and uptime monitors confirm the process is alive without needing a secret. The deep response is a superset of shallow — it includes everything shallow returns plus the `checks` object and a real health status.
264
264
 
265
+ #### The `deep` Option
266
+
267
+ When no `token` is configured, the handler returns a **shallow** response by default. To expose full healthcheck results without requiring token authentication, set `deep: true`:
268
+
269
+ ```typescript
270
+ createHealthcheckHandler({
271
+ registry,
272
+ deep: true, // no token → always return deep response
273
+ });
274
+ ```
275
+
276
+ This is useful for internal services behind a private network where token auth is unnecessary. The `deep` option defaults to `false`.
277
+
278
+ > **Security note:** Using `deep: true` with an empty string token (e.g. `token: ''`) will throw an error at handler creation time. This prevents misconfigured environments (e.g. `VITALS_TOKEN=""`) from silently exposing deep healthcheck data. If you intend to run without authentication, explicitly omit the `token` option or set it to `null`.
279
+
280
+ When both `token` and `deep` are set, the `token` takes precedence — callers must still authenticate to see deep results:
281
+
282
+ | Configuration | No token in request | Valid token | Invalid token |
283
+ |---------------|---------------------|-------------|---------------|
284
+ | `token` set, `deep` unset | Shallow | Deep | 403 |
285
+ | `token` set, `deep: true` | Shallow | Deep | 403 |
286
+ | No `token`, `deep` unset | Shallow | — | — |
287
+ | No `token`, `deep: true` | Deep | — | — |
288
+
265
289
  ### Metadata
266
290
 
267
291
  Attach static key-value pairs that appear in both shallow and deep responses:
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.cjs';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.cjs';
2
2
 
3
3
  /**
4
4
  * Minimal interface for a connected Databricks SQL client.
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.js';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.js';
2
2
 
3
3
  /**
4
4
  * Minimal interface for a connected Databricks SQL client.
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.cjs';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.cjs';
2
2
 
3
3
  interface HttpCheckOptions {
4
4
  /** HTTP method to use. Defaults to 'GET'. */
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.js';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.js';
2
2
 
3
3
  interface HttpCheckOptions {
4
4
  /** HTTP method to use. Defaults to 'GET'. */
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.cjs';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.cjs';
2
2
  import { Pool } from 'pg';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.js';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.js';
2
2
  import { Pool } from 'pg';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.cjs';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.cjs';
2
2
  import Redis from 'ioredis';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { A as AsyncCheckFn } from '../core-BJ2Z0rRi.js';
1
+ import { A as AsyncCheckFn } from '../core-Bee03bJm.js';
2
2
  import Redis from 'ioredis';
3
3
 
4
4
  /**
@@ -26,6 +26,7 @@ interface HealthcheckResponse {
26
26
  readonly status: StatusValue;
27
27
  readonly timestamp: string;
28
28
  readonly checks: Readonly<Record<string, CheckResult>>;
29
+ readonly cachedAt?: string;
29
30
  }
30
31
  interface HealthcheckResponseJson {
31
32
  status: StatusLabel;
@@ -35,6 +36,7 @@ interface HealthcheckResponseJson {
35
36
  latencyMs: number;
36
37
  message: string;
37
38
  }>;
39
+ cachedAt?: string;
38
40
  }
39
41
  declare function toJson(response: HealthcheckResponse): HealthcheckResponseJson;
40
42
  declare function httpStatusCode(status: StatusValue): 200 | 503;
@@ -43,10 +45,13 @@ type AsyncCheckFn = () => Promise<CheckInput>;
43
45
  type SyncCheckFn = () => CheckInput;
44
46
  interface RegistryOptions {
45
47
  defaultTimeout?: number;
48
+ cacheTtlMs?: number;
46
49
  }
47
50
  declare class HealthcheckRegistry {
48
51
  private readonly checks;
49
52
  private readonly defaultTimeout;
53
+ private readonly cacheTtlMs;
54
+ private cache;
50
55
  constructor(options?: RegistryOptions);
51
56
  add(name: string, fn: AsyncCheckFn, options?: {
52
57
  timeout?: number;
@@ -58,8 +63,9 @@ declare class HealthcheckRegistry {
58
63
  timeout?: number;
59
64
  }): (fn: AsyncCheckFn) => AsyncCheckFn;
60
65
  run(): Promise<HealthcheckResponse>;
66
+ private executeChecks;
61
67
  private runSingle;
62
68
  }
63
69
  declare function syncCheck(fn: SyncCheckFn): AsyncCheckFn;
64
70
 
65
- export { type AsyncCheckFn as A, type CheckInput as C, HealthcheckRegistry as H, Status as S, type CheckResult as a, type HealthcheckResponse as b, type HealthcheckResponseJson as c, type StatusLabel as d, type StatusValue as e, type SyncCheckFn as f, statusToLabel as g, httpStatusCode as h, syncCheck as i, statusFromString as s, toJson as t };
71
+ export { type AsyncCheckFn as A, type CheckInput as C, type HealthcheckResponseJson as H, Status as S, type CheckResult as a, HealthcheckRegistry as b, type HealthcheckResponse as c, type StatusLabel as d, type StatusValue as e, type SyncCheckFn as f, statusToLabel as g, httpStatusCode as h, syncCheck as i, statusFromString as s, toJson as t };
@@ -26,6 +26,7 @@ interface HealthcheckResponse {
26
26
  readonly status: StatusValue;
27
27
  readonly timestamp: string;
28
28
  readonly checks: Readonly<Record<string, CheckResult>>;
29
+ readonly cachedAt?: string;
29
30
  }
30
31
  interface HealthcheckResponseJson {
31
32
  status: StatusLabel;
@@ -35,6 +36,7 @@ interface HealthcheckResponseJson {
35
36
  latencyMs: number;
36
37
  message: string;
37
38
  }>;
39
+ cachedAt?: string;
38
40
  }
39
41
  declare function toJson(response: HealthcheckResponse): HealthcheckResponseJson;
40
42
  declare function httpStatusCode(status: StatusValue): 200 | 503;
@@ -43,10 +45,13 @@ type AsyncCheckFn = () => Promise<CheckInput>;
43
45
  type SyncCheckFn = () => CheckInput;
44
46
  interface RegistryOptions {
45
47
  defaultTimeout?: number;
48
+ cacheTtlMs?: number;
46
49
  }
47
50
  declare class HealthcheckRegistry {
48
51
  private readonly checks;
49
52
  private readonly defaultTimeout;
53
+ private readonly cacheTtlMs;
54
+ private cache;
50
55
  constructor(options?: RegistryOptions);
51
56
  add(name: string, fn: AsyncCheckFn, options?: {
52
57
  timeout?: number;
@@ -58,8 +63,9 @@ declare class HealthcheckRegistry {
58
63
  timeout?: number;
59
64
  }): (fn: AsyncCheckFn) => AsyncCheckFn;
60
65
  run(): Promise<HealthcheckResponse>;
66
+ private executeChecks;
61
67
  private runSingle;
62
68
  }
63
69
  declare function syncCheck(fn: SyncCheckFn): AsyncCheckFn;
64
70
 
65
- export { type AsyncCheckFn as A, type CheckInput as C, HealthcheckRegistry as H, Status as S, type CheckResult as a, type HealthcheckResponse as b, type HealthcheckResponseJson as c, type StatusLabel as d, type StatusValue as e, type SyncCheckFn as f, statusToLabel as g, httpStatusCode as h, syncCheck as i, statusFromString as s, toJson as t };
71
+ export { type AsyncCheckFn as A, type CheckInput as C, type HealthcheckResponseJson as H, Status as S, type CheckResult as a, HealthcheckRegistry as b, type HealthcheckResponse as c, type StatusLabel as d, type StatusValue as e, type SyncCheckFn as f, statusToLabel as g, httpStatusCode as h, syncCheck as i, statusFromString as s, toJson as t };
@@ -1,8 +1,9 @@
1
- import { H as HealthcheckRegistry, c as HealthcheckResponseJson } from './core-BJ2Z0rRi.js';
1
+ import { b as HealthcheckRegistry, H as HealthcheckResponseJson } from './core-Bee03bJm.cjs';
2
2
 
3
3
  interface HealthcheckHandlerOptions {
4
4
  registry: HealthcheckRegistry;
5
5
  token?: string | null;
6
+ deep?: boolean;
6
7
  queryParamName?: string;
7
8
  metadata?: Record<string, string | number | boolean>;
8
9
  }
@@ -1,8 +1,9 @@
1
- import { H as HealthcheckRegistry, c as HealthcheckResponseJson } from './core-BJ2Z0rRi.cjs';
1
+ import { b as HealthcheckRegistry, H as HealthcheckResponseJson } from './core-Bee03bJm.js';
2
2
 
3
3
  interface HealthcheckHandlerOptions {
4
4
  registry: HealthcheckRegistry;
5
5
  token?: string | null;
6
+ deep?: boolean;
6
7
  queryParamName?: string;
7
8
  metadata?: Record<string, string | number | boolean>;
8
9
  }
package/dist/index.cjs CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  createHealthcheckHandler: () => createHealthcheckHandler,
26
26
  extractToken: () => extractToken,
27
27
  httpStatusCode: () => httpStatusCode,
28
+ renderHealthcheckHtml: () => renderHealthcheckHtml,
28
29
  statusFromString: () => statusFromString,
29
30
  statusToLabel: () => statusToLabel,
30
31
  syncCheck: () => syncCheck,
@@ -58,7 +59,7 @@ function statusFromString(value) {
58
59
  return mapping[value.toLowerCase()] ?? Status.OUTAGE;
59
60
  }
60
61
  function toJson(response) {
61
- return {
62
+ const json = {
62
63
  status: statusToLabel(response.status),
63
64
  timestamp: response.timestamp,
64
65
  checks: Object.fromEntries(
@@ -68,6 +69,10 @@ function toJson(response) {
68
69
  ])
69
70
  )
70
71
  };
72
+ if (response.cachedAt !== void 0) {
73
+ json.cachedAt = response.cachedAt;
74
+ }
75
+ return json;
71
76
  }
72
77
  function httpStatusCode(status) {
73
78
  return status === Status.HEALTHY ? 200 : 503;
@@ -78,8 +83,11 @@ var import_node_perf_hooks = require("perf_hooks");
78
83
  var HealthcheckRegistry = class {
79
84
  checks = [];
80
85
  defaultTimeout;
86
+ cacheTtlMs;
87
+ cache = null;
81
88
  constructor(options) {
82
89
  this.defaultTimeout = options?.defaultTimeout ?? 5e3;
90
+ this.cacheTtlMs = options?.cacheTtlMs ?? 0;
83
91
  }
84
92
  add(name, fn, options) {
85
93
  if (this.checks.some((c) => c.name === name)) {
@@ -104,6 +112,27 @@ var HealthcheckRegistry = class {
104
112
  };
105
113
  }
106
114
  async run() {
115
+ if (this.cacheTtlMs <= 0) {
116
+ return this.executeChecks();
117
+ }
118
+ if (this.cache !== null && Date.now() < this.cache.expiresAt) {
119
+ return {
120
+ status: this.cache.status,
121
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
122
+ checks: structuredClone(this.cache.checks),
123
+ cachedAt: this.cache.cachedAt
124
+ };
125
+ }
126
+ const response = await this.executeChecks();
127
+ this.cache = {
128
+ checks: structuredClone(response.checks),
129
+ status: response.status,
130
+ cachedAt: response.timestamp,
131
+ expiresAt: Date.now() + this.cacheTtlMs
132
+ };
133
+ return response;
134
+ }
135
+ async executeChecks() {
107
136
  if (this.checks.length === 0) {
108
137
  return {
109
138
  status: Status.HEALTHY,
@@ -189,32 +218,52 @@ function extractToken(options) {
189
218
  }
190
219
 
191
220
  // src/handler.ts
192
- var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks"];
221
+ var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
193
222
  function createHealthcheckHandler(options) {
194
- const { registry, token = null, queryParamName = "token", metadata = {} } = options;
223
+ const { registry, token: rawToken, deep = false, queryParamName = "token", metadata = {} } = options;
224
+ const isEmptyToken = typeof rawToken === "string" && rawToken.trim() === "";
225
+ if (deep && isEmptyToken) {
226
+ throw new Error(
227
+ "Cannot use `deep: true` with an empty string token. This would expose deep healthcheck data without authentication. Either set a non-empty token or explicitly set `token: null`."
228
+ );
229
+ }
230
+ const token = rawToken == null || isEmptyToken ? null : rawToken;
195
231
  for (const key of Object.keys(metadata)) {
196
232
  if (RESERVED_METADATA_KEYS.includes(key)) {
197
233
  throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
198
234
  }
199
235
  }
200
236
  return async (req) => {
201
- if (token !== null) {
202
- const provided = extractToken({
203
- queryParams: req.queryParams,
204
- authorizationHeader: req.authorizationHeader,
205
- queryParamName
206
- });
207
- if (provided === null) {
208
- const body = {
209
- status: "ok",
210
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
211
- ...metadata
237
+ if (token === null) {
238
+ if (deep) {
239
+ const response2 = await registry.run();
240
+ return {
241
+ status: httpStatusCode(response2.status),
242
+ body: { ...metadata, ...toJson(response2) }
212
243
  };
213
- return { status: 200, body };
214
- }
215
- if (!verifyToken(provided, token)) {
216
- return { status: 403, body: { error: "Forbidden" } };
217
244
  }
245
+ const body = {
246
+ status: "ok",
247
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
248
+ ...metadata
249
+ };
250
+ return { status: 200, body };
251
+ }
252
+ const provided = extractToken({
253
+ queryParams: req.queryParams,
254
+ authorizationHeader: req.authorizationHeader,
255
+ queryParamName
256
+ });
257
+ if (provided === null) {
258
+ const body = {
259
+ status: "ok",
260
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
261
+ ...metadata
262
+ };
263
+ return { status: 200, body };
264
+ }
265
+ if (!verifyToken(provided, token)) {
266
+ return { status: 403, body: { error: "Forbidden" } };
218
267
  }
219
268
  const response = await registry.run();
220
269
  return {
@@ -223,6 +272,240 @@ function createHealthcheckHandler(options) {
223
272
  };
224
273
  };
225
274
  }
275
+
276
+ // src/html.ts
277
+ function escapeHtml(str) {
278
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
279
+ }
280
+ function statusColor(status) {
281
+ switch (status) {
282
+ case "healthy":
283
+ case "ok":
284
+ return "#22C55E";
285
+ case "degraded":
286
+ return "#F59E0B";
287
+ case "outage":
288
+ return "#ED1C24";
289
+ default:
290
+ return "#ED1C24";
291
+ }
292
+ }
293
+ var DEEP_KNOWN_KEYS = /* @__PURE__ */ new Set(["status", "timestamp", "checks", "cachedAt"]);
294
+ function isDeepResponse(body) {
295
+ return "checks" in body && "status" in body && body.status !== "ok";
296
+ }
297
+ function isShallowResponse(body) {
298
+ return "status" in body && body.status === "ok";
299
+ }
300
+ function isErrorResponse(body) {
301
+ return "error" in body && !("status" in body);
302
+ }
303
+ function renderStatusBadge(label, color) {
304
+ return `<span style="
305
+ display: inline-flex;
306
+ align-items: center;
307
+ gap: 8px;
308
+ padding: 4px 12px;
309
+ border-radius: 9999px;
310
+ background: ${color}1A;
311
+ font-family: 'Inter', system-ui, sans-serif;
312
+ font-size: 12px;
313
+ font-weight: 600;
314
+ letter-spacing: 0.05em;
315
+ text-transform: uppercase;
316
+ color: ${color};
317
+ "><span style="
318
+ width: 8px;
319
+ height: 8px;
320
+ border-radius: 50%;
321
+ background: ${color};
322
+ box-shadow: 0 0 6px ${color}80;
323
+ "></span>${escapeHtml(label)}</span>`;
324
+ }
325
+ function renderMetadataItems(items) {
326
+ if (items.length === 0) return "";
327
+ return `<div style="
328
+ display: flex;
329
+ flex-wrap: wrap;
330
+ gap: 24px;
331
+ margin-top: 16px;
332
+ ">${items.map(
333
+ ([label, value]) => `<div>
334
+ <div style="
335
+ font-family: 'Inter', system-ui, sans-serif;
336
+ font-size: 10px;
337
+ font-weight: 600;
338
+ letter-spacing: 0.05em;
339
+ text-transform: uppercase;
340
+ color: #A1A1AA;
341
+ margin-bottom: 4px;
342
+ ">${escapeHtml(label)}</div>
343
+ <div style="
344
+ font-family: 'JetBrains Mono', monospace;
345
+ font-size: 13px;
346
+ color: #E4E4E7;
347
+ ">${escapeHtml(value)}</div>
348
+ </div>`
349
+ ).join("")}</div>`;
350
+ }
351
+ function renderCheckRow(name, check) {
352
+ const color = statusColor(check.status);
353
+ return `<div style="
354
+ display: flex;
355
+ align-items: center;
356
+ gap: 12px;
357
+ padding: 12px 0;
358
+ border-top: 1px solid #27272A;
359
+ ">
360
+ <span style="
361
+ width: 8px;
362
+ height: 8px;
363
+ border-radius: 50%;
364
+ background: ${color};
365
+ box-shadow: 0 0 6px ${color}80;
366
+ flex-shrink: 0;
367
+ "></span>
368
+ <span style="
369
+ font-family: 'Inter', system-ui, sans-serif;
370
+ font-size: 12px;
371
+ text-transform: uppercase;
372
+ letter-spacing: 0.05em;
373
+ color: ${color};
374
+ font-weight: 600;
375
+ min-width: 72px;
376
+ ">${escapeHtml(check.status)}</span>
377
+ <span style="
378
+ font-family: 'Inter', system-ui, sans-serif;
379
+ font-size: 14px;
380
+ font-weight: 500;
381
+ color: #E4E4E7;
382
+ flex: 1;
383
+ ">${escapeHtml(name)}</span>
384
+ <span style="
385
+ font-family: 'JetBrains Mono', monospace;
386
+ font-size: 12px;
387
+ color: #A1A1AA;
388
+ min-width: 60px;
389
+ text-align: right;
390
+ ">${escapeHtml(String(check.latencyMs))}ms</span>
391
+ <span style="
392
+ font-family: 'JetBrains Mono', monospace;
393
+ font-size: 12px;
394
+ color: #71717A;
395
+ max-width: 200px;
396
+ overflow: hidden;
397
+ text-overflow: ellipsis;
398
+ white-space: nowrap;
399
+ ">${escapeHtml(check.message)}</span>
400
+ </div>`;
401
+ }
402
+ function renderPage(borderColor, content) {
403
+ return `<!DOCTYPE html>
404
+ <html lang="en">
405
+ <head>
406
+ <meta charset="utf-8">
407
+ <meta name="viewport" content="width=device-width, initial-scale=1">
408
+ <title>Healthcheck</title>
409
+ <style></style>
410
+ </head>
411
+ <body style="
412
+ margin: 0;
413
+ padding: 40px 20px;
414
+ background: #08080A;
415
+ min-height: 100vh;
416
+ display: flex;
417
+ justify-content: center;
418
+ align-items: flex-start;
419
+ box-sizing: border-box;
420
+ ">
421
+ <div style="
422
+ width: 100%;
423
+ max-width: 560px;
424
+ background: #18181B;
425
+ border: 1px solid #27272A;
426
+ border-left: 3px solid ${borderColor};
427
+ border-radius: 8px;
428
+ padding: 24px;
429
+ ">
430
+ ${content}
431
+ </div>
432
+ </body>
433
+ </html>`;
434
+ }
435
+ function renderHealthcheckHtml(body) {
436
+ if (isErrorResponse(body)) {
437
+ const color = "#ED1C24";
438
+ return renderPage(
439
+ color,
440
+ `<div style="display: flex; align-items: center; justify-content: space-between;">
441
+ <span style="
442
+ font-family: 'Inter', system-ui, sans-serif;
443
+ font-size: 18px;
444
+ font-weight: 700;
445
+ color: #E4E4E7;
446
+ ">Healthcheck</span>
447
+ ${renderStatusBadge("ERROR", color)}
448
+ </div>
449
+ <div style="
450
+ margin-top: 16px;
451
+ font-family: 'JetBrains Mono', monospace;
452
+ font-size: 13px;
453
+ color: #EF4444;
454
+ ">${escapeHtml(body.error)}</div>`
455
+ );
456
+ }
457
+ if (isShallowResponse(body)) {
458
+ const color = statusColor("ok");
459
+ const { status: _, timestamp, ...rest } = body;
460
+ const metadataItems = Object.entries(rest).map(
461
+ ([k, v]) => [k, String(v)]
462
+ );
463
+ const allItems = [
464
+ ["timestamp", timestamp],
465
+ ...metadataItems
466
+ ];
467
+ return renderPage(
468
+ color,
469
+ `<div style="display: flex; align-items: center; justify-content: space-between;">
470
+ <span style="
471
+ font-family: 'Inter', system-ui, sans-serif;
472
+ font-size: 18px;
473
+ font-weight: 700;
474
+ color: #E4E4E7;
475
+ ">Healthcheck</span>
476
+ ${renderStatusBadge("OK", color)}
477
+ </div>
478
+ ${renderMetadataItems(allItems)}`
479
+ );
480
+ }
481
+ if (isDeepResponse(body)) {
482
+ const color = statusColor(body.status);
483
+ const { timestamp, checks } = body;
484
+ const metadataItems = Object.entries(body).filter(([k]) => !DEEP_KNOWN_KEYS.has(k)).map(([k, v]) => [k, String(v)]);
485
+ const allItems = [
486
+ ["timestamp", timestamp],
487
+ ...metadataItems
488
+ ];
489
+ const checkRows = Object.entries(checks).sort(([a], [b]) => a.localeCompare(b)).map(([name, check]) => renderCheckRow(name, check)).join("");
490
+ return renderPage(
491
+ color,
492
+ `<div style="display: flex; align-items: center; justify-content: space-between;">
493
+ <span style="
494
+ font-family: 'Inter', system-ui, sans-serif;
495
+ font-size: 18px;
496
+ font-weight: 700;
497
+ color: #E4E4E7;
498
+ ">Healthcheck</span>
499
+ ${renderStatusBadge(body.status, color)}
500
+ </div>
501
+ ${renderMetadataItems(allItems)}
502
+ <div style="margin-top: 20px;">
503
+ ${checkRows}
504
+ </div>`
505
+ );
506
+ }
507
+ return renderPage("#ED1C24", `<pre style="color: #E4E4E7; font-family: 'JetBrains Mono', monospace;">${escapeHtml(JSON.stringify(body, null, 2))}</pre>`);
508
+ }
226
509
  // Annotate the CommonJS export names for ESM import in node:
227
510
  0 && (module.exports = {
228
511
  HealthcheckRegistry,
@@ -230,6 +513,7 @@ function createHealthcheckHandler(options) {
230
513
  createHealthcheckHandler,
231
514
  extractToken,
232
515
  httpStatusCode,
516
+ renderHealthcheckHtml,
233
517
  statusFromString,
234
518
  statusToLabel,
235
519
  syncCheck,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- export { A as AsyncCheckFn, C as CheckInput, a as CheckResult, H as HealthcheckRegistry, b as HealthcheckResponse, c as HealthcheckResponseJson, S as Status, d as StatusLabel, e as StatusValue, f as SyncCheckFn, h as httpStatusCode, s as statusFromString, g as statusToLabel, i as syncCheck, t as toJson } from './core-BJ2Z0rRi.cjs';
2
- export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, b as HealthcheckRequest, S as ShallowResponseJson, c as createHealthcheckHandler } from './handler-Bvf66wzh.cjs';
1
+ import { H as HealthcheckResponseJson } from './core-Bee03bJm.cjs';
2
+ export { A as AsyncCheckFn, C as CheckInput, a as CheckResult, b as HealthcheckRegistry, c as HealthcheckResponse, S as Status, d as StatusLabel, e as StatusValue, f as SyncCheckFn, h as httpStatusCode, s as statusFromString, g as statusToLabel, i as syncCheck, t as toJson } from './core-Bee03bJm.cjs';
3
+ import { S as ShallowResponseJson } from './handler-COH7lot9.cjs';
4
+ export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, b as HealthcheckRequest, c as createHealthcheckHandler } from './handler-COH7lot9.cjs';
3
5
 
4
6
  declare function verifyToken(provided: string, expected: string): boolean;
5
7
  declare function extractToken(options: {
@@ -8,4 +10,9 @@ declare function extractToken(options: {
8
10
  queryParamName?: string;
9
11
  }): string | null;
10
12
 
11
- export { extractToken, verifyToken };
13
+ type HealthcheckBody = HealthcheckResponseJson | ShallowResponseJson | {
14
+ error: string;
15
+ };
16
+ declare function renderHealthcheckHtml(body: HealthcheckBody): string;
17
+
18
+ export { HealthcheckResponseJson, ShallowResponseJson, extractToken, renderHealthcheckHtml, verifyToken };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { A as AsyncCheckFn, C as CheckInput, a as CheckResult, H as HealthcheckRegistry, b as HealthcheckResponse, c as HealthcheckResponseJson, S as Status, d as StatusLabel, e as StatusValue, f as SyncCheckFn, h as httpStatusCode, s as statusFromString, g as statusToLabel, i as syncCheck, t as toJson } from './core-BJ2Z0rRi.js';
2
- export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, b as HealthcheckRequest, S as ShallowResponseJson, c as createHealthcheckHandler } from './handler-R2U3ygLo.js';
1
+ import { H as HealthcheckResponseJson } from './core-Bee03bJm.js';
2
+ export { A as AsyncCheckFn, C as CheckInput, a as CheckResult, b as HealthcheckRegistry, c as HealthcheckResponse, S as Status, d as StatusLabel, e as StatusValue, f as SyncCheckFn, h as httpStatusCode, s as statusFromString, g as statusToLabel, i as syncCheck, t as toJson } from './core-Bee03bJm.js';
3
+ import { S as ShallowResponseJson } from './handler-CVYUad84.js';
4
+ export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, b as HealthcheckRequest, c as createHealthcheckHandler } from './handler-CVYUad84.js';
3
5
 
4
6
  declare function verifyToken(provided: string, expected: string): boolean;
5
7
  declare function extractToken(options: {
@@ -8,4 +10,9 @@ declare function extractToken(options: {
8
10
  queryParamName?: string;
9
11
  }): string | null;
10
12
 
11
- export { extractToken, verifyToken };
13
+ type HealthcheckBody = HealthcheckResponseJson | ShallowResponseJson | {
14
+ error: string;
15
+ };
16
+ declare function renderHealthcheckHtml(body: HealthcheckBody): string;
17
+
18
+ export { HealthcheckResponseJson, ShallowResponseJson, extractToken, renderHealthcheckHtml, verifyToken };