@nexload-sdk/healthcheck-bun 2.1.0 → 3.0.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
@@ -1,6 +1,58 @@
1
1
  # @nexload-sdk/healthcheck-bun
2
2
 
3
- Bun runtime adapter and Bun server metrics for `@nexload-sdk/healthcheck`.
3
+ **Bun runtime adapter and `Bun.serve` metrics checks for `@nexload-sdk/healthcheck`.**
4
+
5
+ [Documentation](https://gecut.github.io/nexload-sdk/packages/healthcheck/bun/) · [API reference](https://gecut.github.io/nexload-sdk/packages/healthcheck/bun/api/)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@nexload-sdk/healthcheck-bun)](https://www.npmjs.com/package/@nexload-sdk/healthcheck-bun)
8
+ ![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)
9
+ ![Module: ESM + CJS](https://img.shields.io/badge/module-ESM%20%2B%20CJS-green.svg)
10
+ ![Runtime: Bun](https://img.shields.io/badge/runtime-Bun-lightgrey.svg)
11
+
12
+ > [!IMPORTANT]
13
+ > A new major release is pending across the healthcheck family in `.changeset/healthcheck-major.md` (import ordering updates, no runtime behavior changes).
14
+
15
+ ## Table of contents
16
+
17
+ - [Overview](#overview)
18
+ - [Philosophy](#philosophy)
19
+ - [Install](#install)
20
+ - [Quick start](#quick-start)
21
+ - [Usage](#usage)
22
+ - [API](#api)
23
+ - [Configuration](#configuration)
24
+ - [Runtime and compatibility](#runtime-and-compatibility)
25
+ - [Caveats](#caveats)
26
+ - [Related packages](#related-packages)
27
+ - [License](#license)
28
+
29
+ ## Overview
30
+
31
+ `@nexload-sdk/healthcheck-bun` provides a `RuntimeAdapter` for Bun (`bunRuntimeAdapter`), a Bun runtime diagnostics check (`bunRuntimeInfoCheck`), and a `Bun.serve` metrics check (`bunServerMetricsCheck`). It solves reporting Bun version, revision, and active request/WebSocket counts inside `@nexload-sdk/healthcheck` reports. It is for Bun HTTP services and APIs.
32
+
33
+ What it is not:
34
+
35
+ - Not an HTTP route handler for Bun (wire `health.run(...)` inside your `Bun.serve` `fetch` handler).
36
+ - Not a cgroup container probe (unlike `@nexload-sdk/healthcheck-node`).
37
+
38
+ ## Philosophy
39
+
40
+ - **Lightweight global inspection:** Reads `globalThis.Bun` and `globalThis.process` safely without crashing if fields are absent.
41
+ - **Diagnostics by default:** `bunRuntimeInfoCheck` and `bunServerMetricsCheck` default to `scopes: ["diagnostics"]` and `critical: false`.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ bun add @nexload-sdk/healthcheck @nexload-sdk/healthcheck-bun
47
+ # or
48
+ pnpm add @nexload-sdk/healthcheck @nexload-sdk/healthcheck-bun
49
+ ```
50
+
51
+ | Package | Range | Required / Optional |
52
+ | --- | --- | --- |
53
+ | *(none)* | — | No peer dependencies (`@nexload-sdk/healthcheck` is a direct dependency) |
54
+
55
+ ## Quick start
4
56
 
5
57
  ```ts
6
58
  import { createHealthManager, shutdownCheck } from "@nexload-sdk/healthcheck";
@@ -11,6 +63,58 @@ const server = Bun.serve({ fetch: () => new Response("ok") });
11
63
  export const health = createHealthManager({
12
64
  service: { name: "bun-api" },
13
65
  runtime: bunRuntimeAdapter(),
14
- checks: [shutdownCheck(), bunServerMetricsCheck(server)]
66
+ checks: [shutdownCheck(), bunServerMetricsCheck(server)],
15
67
  });
16
68
  ```
69
+
70
+ ## Usage
71
+
72
+ ### Checking Bun runtime info
73
+
74
+ ```ts
75
+ import { bunRuntimeInfoCheck } from "@nexload-sdk/healthcheck-bun";
76
+
77
+ const runtimeCheck = bunRuntimeInfoCheck({ scopes: ["diagnostics"] });
78
+ ```
79
+
80
+ `bunRuntimeInfoCheck` reports `"ok"` when `ctx.runtime.getRuntimeInfo().name === "bun"` and `"degraded"` otherwise.
81
+
82
+ ## API
83
+
84
+ ### Root entry (`@nexload-sdk/healthcheck-bun`)
85
+
86
+ | Export | Kind | Summary |
87
+ | --- | --- | --- |
88
+ | `bunRuntimeAdapter` | `function` | `RuntimeAdapter` reading Bun version, revision, uptime, and process memory |
89
+ | `bunRuntimeInfoCheck` | `function` | Check `"bun.runtime"` reporting uptime and runtime details |
90
+ | `bunServerMetricsCheck` | `function` | Check `"bun.server.metrics"` reporting `pendingRequests` and `pendingWebSockets` |
91
+ | `BunServerLike` | `interface` | Structural type matching `Bun.serve()` return object |
92
+
93
+ ## Configuration
94
+
95
+ | Function | Option | Type | Default | Description |
96
+ | --- | --- | --- | --- | --- |
97
+ | `bunRuntimeInfoCheck` | `scopes` | `readonly HealthScope[]` | `["diagnostics"]` | Scopes where the check runs |
98
+ | `bunServerMetricsCheck` | `scopes` | `readonly HealthScope[]` | `["diagnostics"]` | Scopes where the check runs |
99
+
100
+ ## Runtime and compatibility
101
+
102
+ - **Module format:** Dual ESM (`import`) and CJS (`require`).
103
+ - **Runtime:** Designed for Bun.
104
+
105
+ ## Caveats
106
+
107
+ > [!NOTE]
108
+ > `bunRuntimeAdapter()` reads process memory via `process.memoryUsage()` when available and sets `totalBytes`, `constrainedBytes`, `availableBytes`, `availableRatio`, and `usedRatio` to `null` (it does not read Linux cgroups). `memoryCheck()` therefore reports degraded with this adapter.
109
+
110
+ > [!WARNING]
111
+ > Protect endpoints exposing `bun.runtime` or `bun.server.metrics` diagnostics so runtime versions and server load are not leaked publicly.
112
+
113
+ ## Related packages
114
+
115
+ - [healthcheck](../core/README.md) — Core `HealthManager` and runtime-neutral checks
116
+ - [healthcheck-prometheus](../prometheus/README.md) — Prometheus text exporter
117
+
118
+ ## License
119
+
120
+ MIT
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- // @nexload-sdk/healthcheck-bun v2.0.1 (build 2026-07-20T16:57:08.652Z)
1
+ // @nexload-sdk/healthcheck-bun v3.0.0 (build 2026-11-25T11:31:39.771Z)
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import { defineHealthCheck } from \"@nexload-sdk/healthcheck\";\n\nimport type {\n HealthCheckDefinition,\n HealthScope,\n RuntimeAdapter,\n RuntimeMemorySnapshot\n} from \"@nexload-sdk/healthcheck\";\n\ninterface BunGlobalShape {\n version?: string\n revision?: string\n}\n\nexport interface BunServerLike {\n pendingRequests?: number\n pendingWebSockets?: number\n subscriberCount?: (topic: string) => number\n}\n\nfunction getBun (): BunGlobalShape | null {\n return (globalThis as typeof globalThis & { Bun?: BunGlobalShape }).Bun ?? null;\n}\n\nfunction getProcess () {\n return (globalThis as typeof globalThis & { process?: NodeJS.Process }).process;\n}\n\nfunction finitePositive (value: unknown): number | null {\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value\n : null;\n}\n\nfunction memorySnapshot (): RuntimeMemorySnapshot {\n const processLike = getProcess();\n const memory = processLike?.memoryUsage?.();\n\n return {\n rssBytes: finitePositive(memory?.rss),\n heapTotalBytes: finitePositive(memory?.heapTotal),\n heapUsedBytes: finitePositive(memory?.heapUsed),\n externalBytes: finitePositive(memory?.external),\n arrayBuffersBytes: finitePositive(memory?.arrayBuffers),\n constrainedBytes: null,\n availableBytes: null,\n totalBytes: null,\n usedRatio: null,\n availableRatio: null,\n source: memory ? \"process\" : \"none\",\n };\n}\n\nexport function bunRuntimeAdapter (): RuntimeAdapter {\n const bun = getBun();\n const processLike = getProcess();\n\n return {\n name: \"bun\",\n now: () => performance.now(),\n uptimeSeconds: () => finitePositive(processLike?.uptime?.()) ?? null,\n getRuntimeInfo: () => ({\n name: \"bun\",\n version: bun?.version,\n revision: bun?.revision,\n platform: processLike?.platform,\n arch: processLike?.arch,\n pid: processLike?.pid,\n }),\n getMemory: memorySnapshot,\n };\n}\n\nexport function bunRuntimeInfoCheck (options: { scopes?: readonly HealthScope[] } = {}): HealthCheckDefinition<\"bun.runtime\"> {\n return defineHealthCheck({\n name: \"bun.runtime\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run (ctx) {\n const info = ctx.runtime.getRuntimeInfo();\n\n return {\n status: info.name === \"bun\" ? \"ok\" : \"degraded\",\n metrics: { uptimeSeconds: ctx.runtime.uptimeSeconds(), },\n details: { ...info, },\n };\n },\n });\n}\n\nexport function bunServerMetricsCheck (\n server: BunServerLike, options: { scopes?: readonly HealthScope[] } = {}\n): HealthCheckDefinition<\"bun.server.metrics\"> {\n return defineHealthCheck({\n name: \"bun.server.metrics\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run () {\n return {\n status: \"ok\",\n metrics: {\n pendingRequests: server.pendingRequests ?? null,\n pendingWebSockets: server.pendingWebSockets ?? null,\n },\n };\n },\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkC;AAoBlC,SAAS,SAAiC;AACxC,SAAQ,WAA4D,OAAO;AAC7E;AAEA,SAAS,aAAc;AACrB,SAAQ,WAAgE;AAC1E;AAEA,SAAS,eAAgB,OAA+B;AACtD,SAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,QAAQ,IAClE,QACA;AACN;AAEA,SAAS,iBAAyC;AAlClD;AAmCE,QAAM,cAAc,WAAW;AAC/B,QAAM,UAAS,gDAAa,gBAAb;AAEf,SAAO;AAAA,IACL,UAAU,eAAe,iCAAQ,GAAG;AAAA,IACpC,gBAAgB,eAAe,iCAAQ,SAAS;AAAA,IAChD,eAAe,eAAe,iCAAQ,QAAQ;AAAA,IAC9C,eAAe,eAAe,iCAAQ,QAAQ;AAAA,IAC9C,mBAAmB,eAAe,iCAAQ,YAAY;AAAA,IACtD,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,QAAQ,SAAS,YAAY;AAAA,EAC/B;AACF;AAEO,SAAS,oBAAqC;AACnD,QAAM,MAAM,OAAO;AACnB,QAAM,cAAc,WAAW;AAE/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM,YAAY,IAAI;AAAA,IAC3B,eAAe,MAAG;AA5DtB;AA4DyB,6BAAe,gDAAa,WAAb,oCAAuB,KAAK;AAAA;AAAA,IAChE,gBAAgB,OAAO;AAAA,MACrB,MAAM;AAAA,MACN,SAAS,2BAAK;AAAA,MACd,UAAU,2BAAK;AAAA,MACf,UAAU,2CAAa;AAAA,MACvB,MAAM,2CAAa;AAAA,MACnB,KAAK,2CAAa;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,EACb;AACF;AAEO,SAAS,oBAAqB,UAA+C,CAAC,GAAyC;AAC5H,aAAO,sCAAkB;AAAA,IACvB,MAAM;AAAA,IACN,QAAQ,QAAQ,UAAU,CAAC,aAAa;AAAA,IACxC,UAAU;AAAA,IACV,IAAK,KAAK;AACR,YAAM,OAAO,IAAI,QAAQ,eAAe;AAExC,aAAO;AAAA,QACL,QAAQ,KAAK,SAAS,QAAQ,OAAO;AAAA,QACrC,SAAS,EAAE,eAAe,IAAI,QAAQ,cAAc,EAAG;AAAA,QACvD,SAAS,EAAE,GAAG,KAAM;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,SAAS,sBACd,QAAuB,UAA+C,CAAC,GAC1B;AAC7C,aAAO,sCAAkB;AAAA,IACvB,MAAM;AAAA,IACN,QAAQ,QAAQ,UAAU,CAAC,aAAa;AAAA,IACxC,UAAU;AAAA,IACV,MAAO;AACL,aAAO;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,iBAAiB,OAAO,mBAAmB;AAAA,UAC3C,mBAAmB,OAAO,qBAAqB;AAAA,QACjD;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import type {\n HealthCheckDefinition,\n HealthScope,\n RuntimeAdapter,\n RuntimeMemorySnapshot\n} from \"@nexload-sdk/healthcheck\";\n\nimport { defineHealthCheck } from \"@nexload-sdk/healthcheck\";\n\ninterface BunGlobalShape {\n version?: string\n revision?: string\n}\n\nexport interface BunServerLike {\n pendingRequests?: number\n pendingWebSockets?: number\n subscriberCount?: (topic: string) => number\n}\n\nfunction getBun (): BunGlobalShape | null {\n return (globalThis as typeof globalThis & { Bun?: BunGlobalShape }).Bun ?? null;\n}\n\nfunction getProcess () {\n return (globalThis as typeof globalThis & { process?: NodeJS.Process }).process;\n}\n\nfunction finitePositive (value: unknown): number | null {\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value\n : null;\n}\n\nfunction memorySnapshot (): RuntimeMemorySnapshot {\n const processLike = getProcess();\n const memory = processLike?.memoryUsage?.();\n\n return {\n rssBytes: finitePositive(memory?.rss),\n heapTotalBytes: finitePositive(memory?.heapTotal),\n heapUsedBytes: finitePositive(memory?.heapUsed),\n externalBytes: finitePositive(memory?.external),\n arrayBuffersBytes: finitePositive(memory?.arrayBuffers),\n constrainedBytes: null,\n availableBytes: null,\n totalBytes: null,\n usedRatio: null,\n availableRatio: null,\n source: memory ? \"process\" : \"none\",\n };\n}\n\nexport function bunRuntimeAdapter (): RuntimeAdapter {\n const bun = getBun();\n const processLike = getProcess();\n\n return {\n name: \"bun\",\n now: () => performance.now(),\n uptimeSeconds: () => finitePositive(processLike?.uptime?.()) ?? null,\n getRuntimeInfo: () => ({\n name: \"bun\",\n version: bun?.version,\n revision: bun?.revision,\n platform: processLike?.platform,\n arch: processLike?.arch,\n pid: processLike?.pid,\n }),\n getMemory: memorySnapshot,\n };\n}\n\nexport function bunRuntimeInfoCheck (options: { scopes?: readonly HealthScope[] } = {}): HealthCheckDefinition<\"bun.runtime\"> {\n return defineHealthCheck({\n name: \"bun.runtime\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run (ctx) {\n const info = ctx.runtime.getRuntimeInfo();\n\n return {\n status: info.name === \"bun\" ? \"ok\" : \"degraded\",\n metrics: { uptimeSeconds: ctx.runtime.uptimeSeconds(), },\n details: { ...info, },\n };\n },\n });\n}\n\nexport function bunServerMetricsCheck (\n server: BunServerLike, options: { scopes?: readonly HealthScope[] } = {}\n): HealthCheckDefinition<\"bun.server.metrics\"> {\n return defineHealthCheck({\n name: \"bun.server.metrics\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run () {\n return {\n status: \"ok\",\n metrics: {\n pendingRequests: server.pendingRequests ?? null,\n pendingWebSockets: server.pendingWebSockets ?? null,\n },\n };\n },\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,yBAAkC;AAalC,SAAS,SAAiC;AACxC,SAAQ,WAA4D,OAAO;AAC7E;AAEA,SAAS,aAAc;AACrB,SAAQ,WAAgE;AAC1E;AAEA,SAAS,eAAgB,OAA+B;AACtD,SAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,QAAQ,IAClE,QACA;AACN;AAEA,SAAS,iBAAyC;AAlClD;AAmCE,QAAM,cAAc,WAAW;AAC/B,QAAM,UAAS,gDAAa,gBAAb;AAEf,SAAO;AAAA,IACL,UAAU,eAAe,iCAAQ,GAAG;AAAA,IACpC,gBAAgB,eAAe,iCAAQ,SAAS;AAAA,IAChD,eAAe,eAAe,iCAAQ,QAAQ;AAAA,IAC9C,eAAe,eAAe,iCAAQ,QAAQ;AAAA,IAC9C,mBAAmB,eAAe,iCAAQ,YAAY;AAAA,IACtD,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,QAAQ,SAAS,YAAY;AAAA,EAC/B;AACF;AAEO,SAAS,oBAAqC;AACnD,QAAM,MAAM,OAAO;AACnB,QAAM,cAAc,WAAW;AAE/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM,YAAY,IAAI;AAAA,IAC3B,eAAe,MAAG;AA5DtB;AA4DyB,6B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iB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CAC5C;AAmCD,wBAAgB,iBAAiB,IAAK,cAAc,CAkBnD;AAED,wBAAgB,mBAAmB,CAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAAO,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAe5H;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAAO,GACvE,qBAAqB,CAAC,oBAAoB,CAAC,CAe7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,cAAc,EAEf,MAAM,0BAA0B,CAAC;AASlC,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CAC5C;AAmCD,wBAAgB,iBAAiB,IAAK,cAAc,CAkBnD;AAED,wBAAgB,mBAAmB,CAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAAO,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAe5H;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAAO,GACvE,qBAAqB,CAAC,oBAAoB,CAAC,CAe7C"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // @nexload-sdk/healthcheck-bun v2.0.1 (build 2026-07-20T16:57:07.993Z)
1
+ // @nexload-sdk/healthcheck-bun v3.0.0 (build 2026-11-25T11:31:38.584Z)
2
2
 
3
3
  // src/index.ts
4
4
  import { defineHealthCheck } from "@nexload-sdk/healthcheck";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import { defineHealthCheck } from \"@nexload-sdk/healthcheck\";\n\nimport type {\n HealthCheckDefinition,\n HealthScope,\n RuntimeAdapter,\n RuntimeMemorySnapshot\n} from \"@nexload-sdk/healthcheck\";\n\ninterface BunGlobalShape {\n version?: string\n revision?: string\n}\n\nexport interface BunServerLike {\n pendingRequests?: number\n pendingWebSockets?: number\n subscriberCount?: (topic: string) => number\n}\n\nfunction getBun (): BunGlobalShape | null {\n return (globalThis as typeof globalThis & { Bun?: BunGlobalShape }).Bun ?? null;\n}\n\nfunction getProcess () {\n return (globalThis as typeof globalThis & { process?: NodeJS.Process }).process;\n}\n\nfunction finitePositive (value: unknown): number | null {\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value\n : null;\n}\n\nfunction memorySnapshot (): RuntimeMemorySnapshot {\n const processLike = getProcess();\n const memory = processLike?.memoryUsage?.();\n\n return {\n rssBytes: finitePositive(memory?.rss),\n heapTotalBytes: finitePositive(memory?.heapTotal),\n heapUsedBytes: finitePositive(memory?.heapUsed),\n externalBytes: finitePositive(memory?.external),\n arrayBuffersBytes: finitePositive(memory?.arrayBuffers),\n constrainedBytes: null,\n availableBytes: null,\n totalBytes: null,\n usedRatio: null,\n availableRatio: null,\n source: memory ? \"process\" : \"none\",\n };\n}\n\nexport function bunRuntimeAdapter (): RuntimeAdapter {\n const bun = getBun();\n const processLike = getProcess();\n\n return {\n name: \"bun\",\n now: () => performance.now(),\n uptimeSeconds: () => finitePositive(processLike?.uptime?.()) ?? null,\n getRuntimeInfo: () => ({\n name: \"bun\",\n version: bun?.version,\n revision: bun?.revision,\n platform: processLike?.platform,\n arch: processLike?.arch,\n pid: processLike?.pid,\n }),\n getMemory: memorySnapshot,\n };\n}\n\nexport function bunRuntimeInfoCheck (options: { scopes?: readonly HealthScope[] } = {}): HealthCheckDefinition<\"bun.runtime\"> {\n return defineHealthCheck({\n name: \"bun.runtime\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run (ctx) {\n const info = ctx.runtime.getRuntimeInfo();\n\n return {\n status: info.name === \"bun\" ? \"ok\" : \"degraded\",\n metrics: { uptimeSeconds: ctx.runtime.uptimeSeconds(), },\n details: { ...info, },\n };\n },\n });\n}\n\nexport function bunServerMetricsCheck (\n server: BunServerLike, options: { scopes?: readonly HealthScope[] } = {}\n): HealthCheckDefinition<\"bun.server.metrics\"> {\n return defineHealthCheck({\n name: \"bun.server.metrics\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run () {\n return {\n status: \"ok\",\n metrics: {\n pendingRequests: server.pendingRequests ?? null,\n pendingWebSockets: server.pendingWebSockets ?? null,\n },\n };\n },\n });\n}\n"],
5
- "mappings": ";;;AAAA,SAAS,yBAAyB;AAoBlC,SAAS,SAAiC;AACxC,SAAQ,WAA4D,OAAO;AAC7E;AAEA,SAAS,aAAc;AACrB,SAAQ,WAAgE;AAC1E;AAEA,SAAS,eAAgB,OAA+B;AACtD,SAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,QAAQ,IAClE,QACA;AACN;AAEA,SAAS,iBAAyC;AAChD,QAAM,cAAc,WAAW;AAC/B,QAAM,SAAS,aAAa,cAAc;AAE1C,SAAO;AAAA,IACL,UAAU,eAAe,QAAQ,GAAG;AAAA,IACpC,gBAAgB,eAAe,QAAQ,SAAS;AAAA,IAChD,eAAe,eAAe,QAAQ,QAAQ;AAAA,IAC9C,eAAe,eAAe,QAAQ,QAAQ;AAAA,IAC9C,mBAAmB,eAAe,QAAQ,YAAY;AAAA,IACtD,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,QAAQ,SAAS,YA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nexload-sdk/healthcheck\";\n\nimport { defineHealthCheck } from \"@nexload-sdk/healthcheck\";\n\ninterface BunGlobalShape {\n version?: string\n revision?: string\n}\n\nexport interface BunServerLike {\n pendingRequests?: number\n pendingWebSockets?: number\n subscriberCount?: (topic: string) => number\n}\n\nfunction getBun (): BunGlobalShape | null {\n return (globalThis as typeof globalThis & { Bun?: BunGlobalShape }).Bun ?? null;\n}\n\nfunction getProcess () {\n return (globalThis as typeof globalThis & { process?: NodeJS.Process }).process;\n}\n\nfunction finitePositive (value: unknown): number | null {\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value\n : null;\n}\n\nfunction memorySnapshot (): RuntimeMemorySnapshot {\n const processLike = getProcess();\n const memory = processLike?.memoryUsage?.();\n\n return {\n rssBytes: finitePositive(memory?.rss),\n heapTotalBytes: finitePositive(memory?.heapTotal),\n heapUsedBytes: finitePositive(memory?.heapUsed),\n externalBytes: finitePositive(memory?.external),\n arrayBuffersBytes: finitePositive(memory?.arrayBuffers),\n constrainedBytes: null,\n availableBytes: null,\n totalBytes: null,\n usedRatio: null,\n availableRatio: null,\n source: memory ? \"process\" : \"none\",\n };\n}\n\nexport function bunRuntimeAdapter (): RuntimeAdapter {\n const bun = getBun();\n const processLike = getProcess();\n\n return {\n name: \"bun\",\n now: () => performance.now(),\n uptimeSeconds: () => finitePositive(processLike?.uptime?.()) ?? null,\n getRuntimeInfo: () => ({\n name: \"bun\",\n version: bun?.version,\n revision: bun?.revision,\n platform: processLike?.platform,\n arch: processLike?.arch,\n pid: processLike?.pid,\n }),\n getMemory: memorySnapshot,\n };\n}\n\nexport function bunRuntimeInfoCheck (options: { scopes?: readonly HealthScope[] } = {}): HealthCheckDefinition<\"bun.runtime\"> {\n return defineHealthCheck({\n name: \"bun.runtime\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run (ctx) {\n const info = ctx.runtime.getRuntimeInfo();\n\n return {\n status: info.name === \"bun\" ? \"ok\" : \"degraded\",\n metrics: { uptimeSeconds: ctx.runtime.uptimeSeconds(), },\n details: { ...info, },\n };\n },\n });\n}\n\nexport function bunServerMetricsCheck (\n server: BunServerLike, options: { scopes?: readonly HealthScope[] } = {}\n): HealthCheckDefinition<\"bun.server.metrics\"> {\n return defineHealthCheck({\n name: \"bun.server.metrics\",\n scopes: options.scopes ?? [\"diagnostics\"],\n critical: false,\n run () {\n return {\n status: \"ok\",\n metrics: {\n pendingRequests: server.pendingRequests ?? null,\n pendingWebSockets: server.pendingWebSockets ?? null,\n },\n };\n },\n });\n}\n"],
5
+ "mappings": ";;;AAOA,SAAS,yBAAyB;AAalC,SAAS,SAAiC;AACxC,SAAQ,WAA4D,OAAO;AAC7E;AAEA,SAAS,aAAc;AACrB,SAAQ,WAAgE;AAC1E;AAEA,SAAS,eAAgB,OAA+B;AACtD,SAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,QAAQ,IAClE,QACA;AACN;AAEA,SAAS,iBAAyC;AAChD,QAAM,cAAc,WAAW;AAC/B,QAAM,SAAS,aAAa,cAAc;AAE1C,SAAO;AAAA,IACL,UAAU,eAAe,QAAQ,GAAG;AAAA,IACpC,gBAAgB,eAAe,QAAQ,SAAS;AAAA,IAChD,eAAe,eAAe,QAAQ,QAAQ;AAAA,IAC9C,eAAe,eAAe,QAAQ,QAAQ;AAAA,IAC9C,mBAAmB,eAAe,QAAQ,YAAY;AAAA,IACtD,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,QAAQ,SAAS,YAAY;AAAA,EAC/B;AACF;AAEO,SAAS,oBAAqC;AACnD,QAAM,MAAM,OAAO;AACnB,QAAM,cAAc,WAAW;AAE/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM,YAAY,IAAI;AAAA,IAC3B,eAAe,MAAM,eAAe,aAAa,SAAS,CAAC,KAAK;AAAA,IAChE,gBAAgB,OAAO;AAAA,MACrB,MAAM;AAAA,MACN,SAAS,KAAK;AAAA,MACd,UAAU,KAAK;AAAA,MACf,UAAU,aAAa;AAAA,MACvB,MAAM,aAAa;AAAA,MACnB,KAAK,aAAa;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,EACb;AACF;AAEO,SAAS,oBAAqB,UAA+C,CAAC,GAAyC;AAC5H,SAAO,kBAAkB;AAAA,IACvB,MAAM;AAAA,IACN,QAAQ,QAAQ,UAAU,CAAC,aAAa;AAAA,IACxC,UAAU;AAAA,IACV,IAAK,KAAK;AACR,YAAM,OAAO,IAAI,QAAQ,eAAe;AAExC,aAAO;AAAA,QACL,QAAQ,KAAK,SAAS,QAAQ,OAAO;AAAA,QACrC,SAAS,EAAE,eAAe,IAAI,QAAQ,cAAc,EAAG;AAAA,QACvD,SAAS,EAAE,GAAG,KAAM;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,SAAS,sBACd,QAAuB,UAA+C,CAAC,GAC1B;AAC7C,SAAO,kBAAkB;AAAA,IACvB,MAAM;AAAA,IACN,QAAQ,QAAQ,UAAU,CAAC,aAAa;AAAA,IACxC,UAAU;AAAA,IACV,MAAO;AACL,aAAO;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,iBAAiB,OAAO,mBAAmB;AAAA,UAC3C,mBAAmB,OAAO,qBAAqB;AAAA,QACjD;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexload-sdk/healthcheck-bun",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "Bun runtime adapter and Bun server metrics for @nexload-sdk/healthcheck.",
5
5
  "keywords": [
6
6
  "bun",
@@ -31,15 +31,15 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@nexload-sdk/healthcheck": "4.1.0"
34
+ "@nexload-sdk/healthcheck": "5.0.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^25.0.3",
38
38
  "eslint": "^9.39.2",
39
39
  "typescript": "5.9.3",
40
40
  "@nexload-sdk/bundler": "4.0.1",
41
- "@nexload-sdk/typescript-config": "4.0.1",
42
- "@nexload-sdk/eslint-config": "4.0.1"
41
+ "@nexload-sdk/eslint-config": "9.39.2",
42
+ "@nexload-sdk/typescript-config": "5.9.3"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "node esbuild.config.mjs",