@nexusts/health 0.7.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 +41 -0
- package/dist/index.js +381 -0
- package/dist/index.js.map +15 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @nexusts/health
|
|
2
|
+
|
|
3
|
+
> **NexusTS** — Bun-native fullstack framework
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
Health check endpoints (live, ready, startup).
|
|
8
|
+
|
|
9
|
+
Built-in indicators (memory, disk, http, Drizzle ping). k8s-friendly endpoints at `/health/live`, `/health/ready`, `/health/startup`.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
This module is part of the NexusTS monorepo. Each module is published as its own npm package under the `@nexusts/` scope.
|
|
14
|
+
|
|
15
|
+
Most apps start with just the core:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun add @nexusts/core reflect-metadata zod hono
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then add this module only if you need it:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun add @nexusts/health
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Peer dependencies
|
|
28
|
+
|
|
29
|
+
None. This module is fully self-contained.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { /* public API */ } from "@nexusts/health";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
See the [user guide](../../docs/user-guide/health.md) and the [example app](../../examples/) for a working demo.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT — see the root [LICENSE](../../LICENSE).
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
21
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
+
else
|
|
23
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
24
|
+
if (d = decorators[i])
|
|
25
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
+
};
|
|
28
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
29
|
+
var __legacyMetadataTS = (k, v) => {
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
31
|
+
return Reflect.metadata(k, v);
|
|
32
|
+
};
|
|
33
|
+
var __require = import.meta.require;
|
|
34
|
+
|
|
35
|
+
// packages/health/src/types.ts
|
|
36
|
+
class HealthIndicator {
|
|
37
|
+
}
|
|
38
|
+
// packages/health/src/health.service.ts
|
|
39
|
+
import { Inject, Injectable } from "@nexusts/core/decorators/index.js";
|
|
40
|
+
|
|
41
|
+
// packages/health/src/indicators/drizzle.ts
|
|
42
|
+
class DrizzleHealthIndicator {
|
|
43
|
+
name;
|
|
44
|
+
#db;
|
|
45
|
+
#timeoutMs;
|
|
46
|
+
#probe;
|
|
47
|
+
constructor(name, db, options = {}) {
|
|
48
|
+
this.name = name;
|
|
49
|
+
this.#db = db;
|
|
50
|
+
this.#timeoutMs = options.timeoutMs ?? 3000;
|
|
51
|
+
this.#probe = options.probe ?? "SELECT 1";
|
|
52
|
+
}
|
|
53
|
+
async check() {
|
|
54
|
+
const start = Date.now();
|
|
55
|
+
try {
|
|
56
|
+
const probe = this.#probe;
|
|
57
|
+
await Promise.race([
|
|
58
|
+
this.#db.rawQuery(probe),
|
|
59
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`probe timed out after ${this.#timeoutMs}ms`)), this.#timeoutMs))
|
|
60
|
+
]);
|
|
61
|
+
return {
|
|
62
|
+
status: "up",
|
|
63
|
+
data: { latencyMs: Date.now() - start, probe: this.#probe }
|
|
64
|
+
};
|
|
65
|
+
} catch (err) {
|
|
66
|
+
return {
|
|
67
|
+
status: "down",
|
|
68
|
+
message: err instanceof Error ? err.message : String(err),
|
|
69
|
+
data: { latencyMs: Date.now() - start, probe: this.#probe }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// packages/health/src/indicators/index.ts
|
|
76
|
+
class MemoryHealthIndicator {
|
|
77
|
+
name = "memory";
|
|
78
|
+
#threshold;
|
|
79
|
+
constructor(options = {}) {
|
|
80
|
+
this.#threshold = options.threshold ?? 0.9;
|
|
81
|
+
}
|
|
82
|
+
async check() {
|
|
83
|
+
const mem = process.memoryUsage();
|
|
84
|
+
const total = mem.heapTotal;
|
|
85
|
+
const used = mem.heapUsed;
|
|
86
|
+
const ratio = total > 0 ? used / total : 0;
|
|
87
|
+
if (ratio > this.#threshold) {
|
|
88
|
+
return {
|
|
89
|
+
status: "down",
|
|
90
|
+
message: `heap usage ${(ratio * 100).toFixed(1)}% exceeds threshold ${(this.#threshold * 100).toFixed(0)}%`,
|
|
91
|
+
data: { heapUsed: used, heapTotal: total, ratio }
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
status: "up",
|
|
96
|
+
data: { heapUsed: used, heapTotal: total, ratio }
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class DiskHealthIndicator {
|
|
102
|
+
name = "disk";
|
|
103
|
+
#threshold;
|
|
104
|
+
#path;
|
|
105
|
+
constructor(options = {}) {
|
|
106
|
+
this.#threshold = options.threshold ?? 0.1;
|
|
107
|
+
this.#path = options.path ?? process.cwd();
|
|
108
|
+
}
|
|
109
|
+
async check() {
|
|
110
|
+
try {
|
|
111
|
+
const statfs = await import("fs/promises").then((m) => m.statfs).catch(() => null);
|
|
112
|
+
if (!statfs) {
|
|
113
|
+
return { status: "up", message: "statfs unavailable; skipping" };
|
|
114
|
+
}
|
|
115
|
+
const s = await statfs(this.#path);
|
|
116
|
+
const free = s.bavail * s.bsize;
|
|
117
|
+
const total = s.blocks * s.bsize;
|
|
118
|
+
const freeRatio = total > 0 ? free / total : 1;
|
|
119
|
+
if (freeRatio < this.#threshold) {
|
|
120
|
+
return {
|
|
121
|
+
status: "down",
|
|
122
|
+
message: `disk free ${(freeRatio * 100).toFixed(1)}% below threshold ${(this.#threshold * 100).toFixed(0)}%`,
|
|
123
|
+
data: { free, total, freeRatio, path: this.#path }
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
status: "up",
|
|
128
|
+
data: { free, total, freeRatio, path: this.#path }
|
|
129
|
+
};
|
|
130
|
+
} catch (err) {
|
|
131
|
+
return {
|
|
132
|
+
status: "down",
|
|
133
|
+
message: err instanceof Error ? err.message : String(err)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
class HttpHealthIndicator {
|
|
140
|
+
name;
|
|
141
|
+
#url;
|
|
142
|
+
#timeoutMs;
|
|
143
|
+
constructor(name, options) {
|
|
144
|
+
this.name = name;
|
|
145
|
+
this.#url = options.url;
|
|
146
|
+
this.#timeoutMs = options.timeoutMs ?? 3000;
|
|
147
|
+
}
|
|
148
|
+
async check() {
|
|
149
|
+
const ctrl = new AbortController;
|
|
150
|
+
const timer = setTimeout(() => ctrl.abort(), this.#timeoutMs);
|
|
151
|
+
try {
|
|
152
|
+
const res = await fetch(this.#url, { signal: ctrl.signal });
|
|
153
|
+
if (res.status >= 200 && res.status < 300) {
|
|
154
|
+
return { status: "up", data: { status: res.status } };
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
status: "down",
|
|
158
|
+
message: `HTTP ${res.status}`,
|
|
159
|
+
data: { status: res.status }
|
|
160
|
+
};
|
|
161
|
+
} catch (err) {
|
|
162
|
+
return {
|
|
163
|
+
status: "down",
|
|
164
|
+
message: err instanceof Error ? err.message : String(err)
|
|
165
|
+
};
|
|
166
|
+
} finally {
|
|
167
|
+
clearTimeout(timer);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
class CustomPingIndicator {
|
|
173
|
+
name;
|
|
174
|
+
#ping;
|
|
175
|
+
#timeoutMs;
|
|
176
|
+
constructor(name, ping, timeoutMs = 3000) {
|
|
177
|
+
this.name = name;
|
|
178
|
+
this.#ping = ping;
|
|
179
|
+
this.#timeoutMs = timeoutMs;
|
|
180
|
+
}
|
|
181
|
+
async check() {
|
|
182
|
+
const ctrl = new AbortController;
|
|
183
|
+
const timer = setTimeout(() => ctrl.abort(), this.#timeoutMs);
|
|
184
|
+
try {
|
|
185
|
+
await Promise.race([
|
|
186
|
+
Promise.resolve(this.#ping()),
|
|
187
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`ping timed out after ${this.#timeoutMs}ms`)), this.#timeoutMs))
|
|
188
|
+
]);
|
|
189
|
+
return { status: "up" };
|
|
190
|
+
} catch (err) {
|
|
191
|
+
return {
|
|
192
|
+
status: "down",
|
|
193
|
+
message: err instanceof Error ? err.message : String(err)
|
|
194
|
+
};
|
|
195
|
+
} finally {
|
|
196
|
+
clearTimeout(timer);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// packages/health/src/health.service.ts
|
|
202
|
+
class HealthCheckService {
|
|
203
|
+
static TOKEN = Symbol.for("nexus:HealthCheckService");
|
|
204
|
+
indicators = new Map;
|
|
205
|
+
config;
|
|
206
|
+
constructor(config = {}) {
|
|
207
|
+
this.config = config;
|
|
208
|
+
this.registerBuiltIns();
|
|
209
|
+
}
|
|
210
|
+
register(indicator) {
|
|
211
|
+
this.indicators.set(indicator.name, indicator);
|
|
212
|
+
}
|
|
213
|
+
unregister(name) {
|
|
214
|
+
return this.indicators.delete(name);
|
|
215
|
+
}
|
|
216
|
+
list() {
|
|
217
|
+
return [...this.indicators.keys()];
|
|
218
|
+
}
|
|
219
|
+
async check(kind = "readiness") {
|
|
220
|
+
const start = Date.now();
|
|
221
|
+
const indicators = [...this.indicators.values()];
|
|
222
|
+
const settled = await Promise.allSettled(indicators.map((i) => i.check()));
|
|
223
|
+
const entries = indicators.map((i, idx) => {
|
|
224
|
+
const s = settled[idx];
|
|
225
|
+
if (s.status === "fulfilled") {
|
|
226
|
+
return { name: i.name, result: s.value };
|
|
227
|
+
}
|
|
228
|
+
const err = s.reason;
|
|
229
|
+
return {
|
|
230
|
+
name: i.name,
|
|
231
|
+
result: {
|
|
232
|
+
status: "down",
|
|
233
|
+
message: err instanceof Error ? err.message : String(err)
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
const status = entries.every((e) => e.result.status === "up") ? "up" : "down";
|
|
238
|
+
return {
|
|
239
|
+
status,
|
|
240
|
+
results: entries,
|
|
241
|
+
durationMs: Date.now() - start,
|
|
242
|
+
timestamp: new Date().toISOString()
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
registerBuiltIns() {
|
|
246
|
+
const bi = this.config.builtIn ?? {};
|
|
247
|
+
if (bi.memory) {
|
|
248
|
+
const opts = typeof bi.memory === "object" ? bi.memory : {};
|
|
249
|
+
this.register(new MemoryHealthIndicator(opts));
|
|
250
|
+
}
|
|
251
|
+
if (bi.disk) {
|
|
252
|
+
this.register(new DiskHealthIndicator(bi.disk));
|
|
253
|
+
}
|
|
254
|
+
if (bi.http) {
|
|
255
|
+
const host = (() => {
|
|
256
|
+
try {
|
|
257
|
+
return new URL(bi.http.url).host || "http";
|
|
258
|
+
} catch {
|
|
259
|
+
return "http";
|
|
260
|
+
}
|
|
261
|
+
})();
|
|
262
|
+
this.register(new HttpHealthIndicator(host, bi.http));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
HealthCheckService = __legacyDecorateClassTS([
|
|
267
|
+
Injectable(),
|
|
268
|
+
__legacyDecorateParamTS(0, Inject("HEALTH_CONFIG")),
|
|
269
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
270
|
+
typeof HealthConfig === "undefined" ? Object : HealthConfig
|
|
271
|
+
])
|
|
272
|
+
], HealthCheckService);
|
|
273
|
+
// packages/health/src/health.controller.ts
|
|
274
|
+
import { Controller, Get, Req, Res, Inject as Inject2 } from "@nexusts/core/decorators/index.js";
|
|
275
|
+
class HealthController {
|
|
276
|
+
health;
|
|
277
|
+
constructor(health) {
|
|
278
|
+
this.health = health;
|
|
279
|
+
}
|
|
280
|
+
async live(c, _res) {
|
|
281
|
+
return this.respond(c, "liveness", this.health.config.livenessPath ?? "/health/live");
|
|
282
|
+
}
|
|
283
|
+
async ready(c, _res) {
|
|
284
|
+
return this.respond(c, "readiness", this.health.config.readinessPath ?? "/health/ready");
|
|
285
|
+
}
|
|
286
|
+
async startup(c, _res) {
|
|
287
|
+
return this.respond(c, "startup", this.health.config.startupPath ?? "/health/startup");
|
|
288
|
+
}
|
|
289
|
+
async respond(c, kind, _configuredPath) {
|
|
290
|
+
const result = await this.health.check(kind);
|
|
291
|
+
const status = result.status === "up" ? 200 : 503;
|
|
292
|
+
return c.json(result, status);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
__legacyDecorateClassTS([
|
|
296
|
+
Get("/health/live"),
|
|
297
|
+
__legacyDecorateParamTS(0, Req()),
|
|
298
|
+
__legacyDecorateParamTS(1, Res()),
|
|
299
|
+
__legacyMetadataTS("design:type", Function),
|
|
300
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
301
|
+
typeof Context === "undefined" ? Object : Context,
|
|
302
|
+
typeof Response === "undefined" ? Object : Response
|
|
303
|
+
]),
|
|
304
|
+
__legacyMetadataTS("design:returntype", Promise)
|
|
305
|
+
], HealthController.prototype, "live", null);
|
|
306
|
+
__legacyDecorateClassTS([
|
|
307
|
+
Get("/health/ready"),
|
|
308
|
+
__legacyDecorateParamTS(0, Req()),
|
|
309
|
+
__legacyDecorateParamTS(1, Res()),
|
|
310
|
+
__legacyMetadataTS("design:type", Function),
|
|
311
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
312
|
+
typeof Context === "undefined" ? Object : Context,
|
|
313
|
+
typeof Response === "undefined" ? Object : Response
|
|
314
|
+
]),
|
|
315
|
+
__legacyMetadataTS("design:returntype", Promise)
|
|
316
|
+
], HealthController.prototype, "ready", null);
|
|
317
|
+
__legacyDecorateClassTS([
|
|
318
|
+
Get("/health/startup"),
|
|
319
|
+
__legacyDecorateParamTS(0, Req()),
|
|
320
|
+
__legacyDecorateParamTS(1, Res()),
|
|
321
|
+
__legacyMetadataTS("design:type", Function),
|
|
322
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
323
|
+
typeof Context === "undefined" ? Object : Context,
|
|
324
|
+
typeof Response === "undefined" ? Object : Response
|
|
325
|
+
]),
|
|
326
|
+
__legacyMetadataTS("design:returntype", Promise)
|
|
327
|
+
], HealthController.prototype, "startup", null);
|
|
328
|
+
HealthController = __legacyDecorateClassTS([
|
|
329
|
+
Controller(),
|
|
330
|
+
__legacyDecorateParamTS(0, Inject2(HealthCheckService.TOKEN)),
|
|
331
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
332
|
+
typeof HealthCheckService === "undefined" ? Object : HealthCheckService
|
|
333
|
+
])
|
|
334
|
+
], HealthController);
|
|
335
|
+
// packages/health/src/health.module.ts
|
|
336
|
+
import"reflect-metadata";
|
|
337
|
+
import { Module } from "@nexusts/core/decorators/module.js";
|
|
338
|
+
class HealthModule {
|
|
339
|
+
static forRoot(config = {}) {
|
|
340
|
+
class ConfiguredHealthModule {
|
|
341
|
+
}
|
|
342
|
+
ConfiguredHealthModule = __legacyDecorateClassTS([
|
|
343
|
+
Module({
|
|
344
|
+
controllers: [HealthController],
|
|
345
|
+
providers: [
|
|
346
|
+
HealthCheckService,
|
|
347
|
+
{ provide: HealthCheckService.TOKEN, useExisting: HealthCheckService },
|
|
348
|
+
{ provide: "HEALTH_CONFIG", useValue: config }
|
|
349
|
+
],
|
|
350
|
+
exports: [HealthCheckService, HealthCheckService.TOKEN]
|
|
351
|
+
})
|
|
352
|
+
], ConfiguredHealthModule);
|
|
353
|
+
Object.defineProperty(ConfiguredHealthModule, "name", {
|
|
354
|
+
value: "ConfiguredHealthModule"
|
|
355
|
+
});
|
|
356
|
+
return ConfiguredHealthModule;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
HealthModule = __legacyDecorateClassTS([
|
|
360
|
+
Module({
|
|
361
|
+
controllers: [HealthController],
|
|
362
|
+
providers: [
|
|
363
|
+
HealthCheckService,
|
|
364
|
+
{ provide: HealthCheckService.TOKEN, useExisting: HealthCheckService }
|
|
365
|
+
],
|
|
366
|
+
exports: [HealthCheckService, HealthCheckService.TOKEN]
|
|
367
|
+
})
|
|
368
|
+
], HealthModule);
|
|
369
|
+
export {
|
|
370
|
+
MemoryHealthIndicator,
|
|
371
|
+
HttpHealthIndicator,
|
|
372
|
+
HealthModule,
|
|
373
|
+
HealthIndicator,
|
|
374
|
+
HealthController,
|
|
375
|
+
HealthCheckService,
|
|
376
|
+
DiskHealthIndicator,
|
|
377
|
+
CustomPingIndicator
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
//# debugId=201F91F73B0D621064756E2164756E21
|
|
381
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/types.ts", "../src/health.service.ts", "../src/indicators/drizzle.ts", "../src/indicators/index.ts", "../src/health.controller.ts", "../src/health.module.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Health check types — the contract for `nexusjs/health`.\n *\n * Mirrors `@nestjs/terminus` and `@adonisjs/health`. Three check\n * kinds:\n *\n * - **Liveness** — am I alive? Used by Kubernetes to decide when\n * to restart the pod. Should be a fast, in-process check.\n *\n * - **Readiness** — am I ready to serve traffic? Used by load\n * balancers and K8s to decide when to send requests. May include\n * DB / cache pings.\n *\n * - **Startup** — has my initialization finished? Used by K8s to\n * gate deployment rollouts.\n *\n * Each check returns a `HealthIndicatorResult`. `status: 'up'` means\n * the check passed; `down` means it failed (the indicator's data\n * carries the error message).\n */\n\nexport type HealthStatus = \"up\" | \"down\";\n\nexport interface HealthIndicatorResult<T = unknown> {\n\t/** Whether the check passed. */\n\tstatus: HealthStatus;\n\t/** Optional data attached to the check (e.g. ping latency). */\n\tdata?: T;\n\t/** Error message when status is 'down'. */\n\tmessage?: string;\n}\n\n/**\n * A single health indicator. Indicators are usually singletons that\n * wrap a connection (DB, cache, HTTP API). The `check()` method\n * performs a fast liveness probe.\n *\n * class DbHealthIndicator extends HealthIndicator {\n * name = 'database';\n * async check() {\n * await this.db.ping();\n * return { status: 'up' };\n * }\n * }\n */\nexport abstract class HealthIndicator {\n\tabstract readonly name: string;\n\tabstract check(): Promise<HealthIndicatorResult>;\n}\n\n/** Result of one check plus its indicator name. */\nexport interface HealthCheckEntry {\n\tname: string;\n\tresult: HealthIndicatorResult;\n}\n\n/** Result of `HealthCheckService.check([...])`. */\nexport interface HealthCheckResult {\n\t/** Aggregate status. `'up'` iff every indicator returned `'up'`. */\n\tstatus: HealthStatus;\n\t/** Per-indicator results. */\n\tresults: HealthCheckEntry[];\n\t/** Total wall-clock time (ms). */\n\tdurationMs: number;\n\t/** ISO timestamp. */\n\ttimestamp: string;\n}\n\n/** Which kind of check we're running. */\nexport type HealthCheckKind = \"liveness\" | \"readiness\" | \"startup\";\n\n/** Configuration for the HealthModule. */\nexport interface HealthConfig {\n\t/**\n\t * Path for the liveness probe. Default: `/health/live`.\n\t * Set to null to disable.\n\t */\n\tlivenessPath?: string | null;\n\t/**\n\t * Path for the readiness probe. Default: `/health/ready`.\n\t */\n\treadinessPath?: string | null;\n\t/**\n\t * Path for the startup probe. Default: `/health/startup`.\n\t */\n\tstartupPath?: string | null;\n\t/**\n\t * Optional token to gate the health endpoints. When set, requests\n\t * must include `Authorization: Bearer <token>`. Useful for\n\t * protecting internal health endpoints from public exposure.\n\t */\n\tauthToken?: string;\n\t/**\n\t * Built-in indicators to register automatically. Currently\n\t * supports 'memory' (heap pressure). 'disk' and 'http' require\n\t * additional config (see config docs).\n\t */\n\tbuiltIn?: {\n\t\tmemory?: boolean | { threshold?: number /* heap pressure 0-1 */ };\n\t\tdisk?: { threshold?: number /* fraction free, e.g. 0.1 */; path?: string };\n\t\thttp?: { url: string; timeoutMs?: number };\n\t};\n}\n",
|
|
6
|
+
"/**\n * `HealthCheckService` — runs a list of indicators in parallel and\n * aggregates the result.\n *\n * Typically injected into a controller that mounts the\n * `/health/live`, `/health/ready`, `/health/startup` endpoints.\n */\n\nimport { Inject, Injectable } from \"@nexusts/core/decorators/index.js\";\nimport type {\n\tHealthCheckResult,\n\tHealthCheckEntry,\n\tHealthIndicator,\n\tHealthIndicatorResult,\n\tHealthCheckKind,\n\tHealthConfig,\n} from \"./types.js\";\nimport {\n\tMemoryHealthIndicator,\n\tDiskHealthIndicator,\n\tHttpHealthIndicator,\n} from \"./indicators/index.js\";\n\n@Injectable()\nexport class HealthCheckService {\n\t/** DI token — use with `@Inject(HealthCheckService.TOKEN)`. */\n\tstatic readonly TOKEN = Symbol.for(\"nexus:HealthCheckService\");\n\n\t/** Registered indicators keyed by name. */\n\tindicators = new Map<string, HealthIndicator>();\n\t/** Public, read-only view of the resolved config. */\n\tconfig: HealthConfig;\n\n\tconstructor(@Inject(\"HEALTH_CONFIG\") config: HealthConfig = {}) {\n\t\tthis.config = config;\n\t\tthis.registerBuiltIns();\n\t}\n\n\t/**\n\t * Register an indicator at runtime (e.g. a DB-specific indicator\n\t * from a feature module).\n\t */\n\tregister(indicator: HealthIndicator): void {\n\t\tthis.indicators.set(indicator.name, indicator);\n\t}\n\n\t/** Remove a registered indicator. */\n\tunregister(name: string): boolean {\n\t\treturn this.indicators.delete(name);\n\t}\n\n\t/** List registered indicator names. */\n\tlist(): string[] {\n\t\treturn [...this.indicators.keys()];\n\t}\n\n\t/**\n\t * Run all registered indicators in parallel and aggregate.\n\t *\n\t * await health.check() → 200 if all 'up', 503 if any 'down'.\n\t */\n\tasync check(kind: HealthCheckKind = \"readiness\"): Promise<HealthCheckResult> {\n\t\tconst start = Date.now();\n\t\tconst indicators = [...this.indicators.values()];\n\t\tconst settled = await Promise.allSettled(\n\t\t\tindicators.map((i) => i.check()),\n\t\t);\n\t\tconst entries: HealthCheckEntry[] = indicators.map((i, idx) => {\n\t\t\tconst s = settled[idx]!;\n\t\t\tif (s.status === \"fulfilled\") {\n\t\t\t\treturn { name: i.name, result: s.value };\n\t\t\t}\n\t\t\tconst err = s.reason;\n\t\t\treturn {\n\t\t\t\tname: i.name,\n\t\t\t\tresult: {\n\t\t\t\t\tstatus: \"down\",\n\t\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t\tconst status = entries.every((e) => e.result.status === \"up\")\n\t\t\t? \"up\"\n\t\t\t: \"down\";\n\t\treturn {\n\t\t\tstatus,\n\t\t\tresults: entries,\n\t\t\tdurationMs: Date.now() - start,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t};\n\t}\n\n\t// ===========================================================================\n\t// Internal\n\t// ===========================================================================\n\n\tprivate registerBuiltIns(): void {\n\t\tconst bi = this.config.builtIn ?? {};\n\t\tif (bi.memory) {\n\t\t\tconst opts = typeof bi.memory === \"object\" ? bi.memory : {};\n\t\t\tthis.register(new MemoryHealthIndicator(opts));\n\t\t}\n\t\tif (bi.disk) {\n\t\t\tthis.register(new DiskHealthIndicator(bi.disk));\n\t\t}\n\t\tif (bi.http) {\n\t\t\t// Default name is derived from the URL host.\n\t\t\tconst host = (() => {\n\t\t\t\ttry {\n\t\t\t\t\treturn new URL(bi.http.url).host || \"http\";\n\t\t\t\t} catch {\n\t\t\t\t\treturn \"http\";\n\t\t\t\t}\n\t\t\t})();\n\t\t\tthis.register(new HttpHealthIndicator(host, bi.http));\n\t\t}\n\t}\n}",
|
|
7
|
+
"/**\n * DrizzleHealthIndicator — runs a `SELECT 1` against the database.\n *\n * new DrizzleHealthIndicator('database', drizzleService, { timeoutMs: 3000 })\n */\nimport type { HealthIndicator, HealthIndicatorResult } from \"../types.js\";\n\nexport class DrizzleHealthIndicator implements HealthIndicator {\n\treadonly name: string;\n\t#db: { rawQuery<T = unknown>(sql: string, params?: unknown[]): Promise<T[]> };\n\t#timeoutMs: number;\n\t/** Optional probe SQL. Default: 'SELECT 1'. */\n\t#probe: string;\n\n\tconstructor(\n\t\tname: string,\n\t\tdb: {\n\t\t\trawQuery<T = unknown>(sql: string, params?: unknown[]): Promise<T[]>;\n\t\t},\n\t\toptions: { timeoutMs?: number; probe?: string } = {},\n\t) {\n\t\tthis.name = name;\n\t\tthis.#db = db;\n\t\tthis.#timeoutMs = options.timeoutMs ?? 3000;\n\t\tthis.#probe = options.probe ?? \"SELECT 1\";\n\t}\n\n\tasync check(): Promise<HealthIndicatorResult> {\n\t\tconst start = Date.now();\n\t\ttry {\n\t\t\tconst probe = this.#probe;\n\t\t\tawait Promise.race([\n\t\t\t\tthis.#db.rawQuery(probe),\n\t\t\t\tnew Promise<never>((_, reject) =>\n\t\t\t\t\tsetTimeout(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\treject(new Error(`probe timed out after ${this.#timeoutMs}ms`)),\n\t\t\t\t\t\tthis.#timeoutMs,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t]);\n\t\t\treturn {\n\t\t\t\tstatus: \"up\",\n\t\t\t\tdata: { latencyMs: Date.now() - start, probe: this.#probe },\n\t\t\t};\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tstatus: \"down\",\n\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t\tdata: { latencyMs: Date.now() - start, probe: this.#probe },\n\t\t\t};\n\t\t}\n\t}\n}\n",
|
|
8
|
+
"/**\n * Built-in health indicators.\n *\n * Each one extends `HealthIndicator` and lives in this folder so the\n * core service stays small. New built-ins (DB, Redis, ...) can be\n * added here.\n */\n\nexport { DrizzleHealthIndicator } from \"./drizzle.js\";\n\nimport type { HealthIndicator, HealthIndicatorResult } from \"../types.js\";\n\n/**\n * Memory pressure indicator. Reports `'down'` when heap usage\n * exceeds the configured threshold (default: 0.9 = 90%).\n */\nexport class MemoryHealthIndicator implements HealthIndicator {\n\treadonly name = \"memory\";\n\t#threshold: number;\n\n\tconstructor(options: { threshold?: number } = {}) {\n\t\tthis.#threshold = options.threshold ?? 0.9;\n\t}\n\n\tasync check(): Promise<HealthIndicatorResult> {\n\t\tconst mem = process.memoryUsage();\n\t\tconst total = mem.heapTotal;\n\t\tconst used = mem.heapUsed;\n\t\tconst ratio = total > 0 ? used / total : 0;\n\t\tif (ratio > this.#threshold) {\n\t\t\treturn {\n\t\t\t\tstatus: \"down\",\n\t\t\t\tmessage: `heap usage ${(ratio * 100).toFixed(1)}% exceeds threshold ${(this.#threshold * 100).toFixed(0)}%`,\n\t\t\t\tdata: { heapUsed: used, heapTotal: total, ratio },\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tstatus: \"up\",\n\t\t\tdata: { heapUsed: used, heapTotal: total, ratio },\n\t\t};\n\t}\n}\n\n/**\n * Disk space indicator. Reports `'down'` when free fraction falls\n * below the threshold.\n */\nexport class DiskHealthIndicator implements HealthIndicator {\n\treadonly name = \"disk\";\n\t#threshold: number;\n\t#path: string;\n\n\tconstructor(options: { threshold?: number; path?: string } = {}) {\n\t\tthis.#threshold = options.threshold ?? 0.1; // 10% free\n\t\tthis.#path = options.path ?? process.cwd();\n\t}\n\n\tasync check(): Promise<HealthIndicatorResult> {\n\t\ttry {\n\t\t\t// Best-effort: rely on Bun / Node to throw if statfs is unsupported.\n\t\t\t// We use a tiny shell-out only when the runtime exposes one.\n\t\t\t// Fall back to 'up' if we can't tell.\n\t\t\tconst statfs = (await import(\"node:fs/promises\")\n\t\t\t\t.then((m) => m.statfs)\n\t\t\t\t.catch(() => null)) as\n\t\t\t\t| ((p: string) => Promise<{\n\t\t\t\t\t\tbavail: number;\n\t\t\t\t\t\tbsize: number;\n\t\t\t\t\t\tblocks: number;\n\t\t\t\t\t\tbfree: number;\n\t\t\t\t }>)\n\t\t\t\t| null;\n\t\t\tif (!statfs) {\n\t\t\t\treturn { status: \"up\", message: \"statfs unavailable; skipping\" };\n\t\t\t}\n\t\t\tconst s = await statfs(this.#path);\n\t\t\tconst free = s.bavail * s.bsize;\n\t\t\tconst total = s.blocks * s.bsize;\n\t\t\tconst freeRatio = total > 0 ? free / total : 1;\n\t\t\tif (freeRatio < this.#threshold) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"down\",\n\t\t\t\t\tmessage: `disk free ${(freeRatio * 100).toFixed(1)}% below threshold ${(this.#threshold * 100).toFixed(0)}%`,\n\t\t\t\t\tdata: { free, total, freeRatio, path: this.#path },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: \"up\",\n\t\t\t\tdata: { free, total, freeRatio, path: this.#path },\n\t\t\t};\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tstatus: \"down\",\n\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * HTTP ping indicator. GETs a URL and reports `'up'` on any 2xx.\n */\nexport class HttpHealthIndicator implements HealthIndicator {\n\treadonly name: string;\n\t#url: string;\n\t#timeoutMs: number;\n\n\tconstructor(name: string, options: { url: string; timeoutMs?: number }) {\n\t\tthis.name = name;\n\t\tthis.#url = options.url;\n\t\tthis.#timeoutMs = options.timeoutMs ?? 3000;\n\t}\n\n\tasync check(): Promise<HealthIndicatorResult> {\n\t\tconst ctrl = new AbortController();\n\t\tconst timer = setTimeout(() => ctrl.abort(), this.#timeoutMs);\n\t\ttry {\n\t\t\tconst res = await fetch(this.#url, { signal: ctrl.signal });\n\t\t\tif (res.status >= 200 && res.status < 300) {\n\t\t\t\treturn { status: \"up\", data: { status: res.status } };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: \"down\",\n\t\t\t\tmessage: `HTTP ${res.status}`,\n\t\t\t\tdata: { status: res.status },\n\t\t\t};\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tstatus: \"down\",\n\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t};\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n}\n\n/**\n * User-supplied ping indicator. Wrap a `ping()` function — typically\n * a DB driver's health check.\n *\n * new CustomPingIndicator('database', async () => db.ping())\n */\nexport class CustomPingIndicator implements HealthIndicator {\n\treadonly name: string;\n\t#ping: () => Promise<void> | void;\n\t#timeoutMs: number;\n\n\tconstructor(\n\t\tname: string,\n\t\tping: () => Promise<void> | void,\n\t\ttimeoutMs = 3000,\n\t) {\n\t\tthis.name = name;\n\t\tthis.#ping = ping;\n\t\tthis.#timeoutMs = timeoutMs;\n\t}\n\n\tasync check(): Promise<HealthIndicatorResult> {\n\t\tconst ctrl = new AbortController();\n\t\tconst timer = setTimeout(() => ctrl.abort(), this.#timeoutMs);\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tPromise.resolve(this.#ping()),\n\t\t\t\tnew Promise<never>((_, reject) =>\n\t\t\t\t\tsetTimeout(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\treject(new Error(`ping timed out after ${this.#timeoutMs}ms`)),\n\t\t\t\t\t\tthis.#timeoutMs,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t]);\n\t\t\treturn { status: \"up\" };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tstatus: \"down\",\n\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t};\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n}\n",
|
|
9
|
+
"/**\n * `HealthController` — built-in `/health/live`, `/health/ready`,\n * `/health/startup` endpoints.\n *\n * Mount `HealthModule.forRoot({...})` in your app module to get\n * these routes automatically. Override paths or add an auth token\n * via `HealthConfig`.\n */\n\nimport { Controller, Get, Req, Res, Inject } from \"@nexusts/core/decorators/index.js\";\nimport type { Context } from \"hono\";\nimport { HealthCheckService } from \"./health.service.js\";\nimport type { HealthCheckKind, HealthConfig } from \"./types.js\";\n\n@Controller()\nexport class HealthController {\n\tconstructor(@Inject(HealthCheckService.TOKEN) private readonly health: HealthCheckService) {}\n\n\t@Get(\"/health/live\")\n\tasync live(@Req() c: Context, @Res() _res: Response) {\n\t\treturn this.respond(c, \"liveness\", this.health.config.livenessPath ?? \"/health/live\");\n\t}\n\n\t@Get(\"/health/ready\")\n\tasync ready(@Req() c: Context, @Res() _res: Response) {\n\t\treturn this.respond(c, \"readiness\", this.health.config.readinessPath ?? \"/health/ready\");\n\t}\n\n\t@Get(\"/health/startup\")\n\tasync startup(@Req() c: Context, @Res() _res: Response) {\n\t\treturn this.respond(c, \"startup\", this.health.config.startupPath ?? \"/health/startup\");\n\t}\n\n\tprivate async respond(c: Context, kind: HealthCheckKind, _configuredPath: string) {\n\t\tconst result = await this.health.check(kind);\n\t\tconst status = result.status === \"up\" ? 200 : 503;\n\t\treturn c.json(result, status);\n\t}\n}\n\n// Augment HealthCheckService to expose config (used by the controller).\ndeclare module \"./health.service.js\" {\n\tinterface HealthCheckService {\n\t\tconfig: HealthConfig;\n\t}\n}",
|
|
10
|
+
"/**\n * `HealthModule` — drop-in module for `/health/live`, `/health/ready`,\n * `/health/startup` endpoints.\n *\n * Usage:\n * @Module({\n * imports: [\n * HealthModule.forRoot({\n * builtIn: {\n * memory: true,\n * disk: { threshold: 0.1 },\n * http: { url: 'https://api.stripe.com/v1/healthcheck' },\n * },\n * }),\n * ],\n * })\n * export class AppModule {}\n *\n * Then `/health/live`, `/health/ready`, `/health/startup` respond\n * with a JSON body. Status 200 on `'up'`, 503 on `'down'`.\n */\n\nimport \"reflect-metadata\";\nimport { Module } from \"@nexusts/core/decorators/module.js\";\nimport { HealthCheckService } from \"./health.service.js\";\nimport { HealthController } from \"./health.controller.js\";\nimport type { HealthConfig } from \"./types.js\";\n\n@Module({\n\tcontrollers: [HealthController],\n\tproviders: [\n\t\tHealthCheckService,\n\t\t{ provide: HealthCheckService.TOKEN, useExisting: HealthCheckService },\n\t],\n\texports: [HealthCheckService, HealthCheckService.TOKEN],\n})\nexport class HealthModule {\n\tstatic forRoot(config: HealthConfig = {}) {\n\t\t@Module({\n\t\t\tcontrollers: [HealthController],\n\t\t\tproviders: [\n\t\t\t\tHealthCheckService,\n\t\t\t\t{ provide: HealthCheckService.TOKEN, useExisting: HealthCheckService },\n\t\t\t\t{ provide: \"HEALTH_CONFIG\", useValue: config },\n\t\t\t],\n\t\t\texports: [HealthCheckService, HealthCheckService.TOKEN],\n\t\t})\n\t\tclass ConfiguredHealthModule {}\n\n\t\tObject.defineProperty(ConfiguredHealthModule, \"name\", {\n\t\t\tvalue: \"ConfiguredHealthModule\",\n\t\t});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,iBASN;AAKA;AAAA,EADL,IAAI,iBAAiB;AAAA,EACP,+BAAI;AAAA,EAAe,+BAAI;AAAA,EAAhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAdM,iBAcN;AAdM,mBAAN;AAAA,EADN,WAAW;AAAA,EAEE,mCAAO,mBAAmB,KAAK;AAAA,EADtC;AAAA;AAAA;AAAA,GAAM;;ACOb;AACA;AAaO,MAAM,aAAa;AAAA,SAClB,OAAO,CAAC,SAAuB,CAAC,GAAG;AAAA,IAUzC,MAAM,uBAAuB;AAAA,IAAC;AAAA,IAAxB,yBAAN;AAAA,MATC,OAAO;AAAA,QACP,aAAa,CAAC,gBAAgB;AAAA,QAC9B,WAAW;AAAA,UACV;AAAA,UACA,EAAE,SAAS,mBAAmB,OAAO,aAAa,mBAAmB;AAAA,UACrE,EAAE,SAAS,iBAAiB,UAAU,OAAO;AAAA,QAC9C;AAAA,QACA,SAAS,CAAC,oBAAoB,mBAAmB,KAAK;AAAA,MACvD,CAAC;AAAA,OACK;AAAA,IAEN,OAAO,eAAe,wBAAwB,QAAQ;AAAA,MACrD,OAAO;AAAA,IACR,CAAC;AAAA,IAED,OAAO;AAAA;AAET;AAnBa,eAAN;AAAA,EARN,OAAO;AAAA,IACP,aAAa,CAAC,gBAAgB;AAAA,IAC9B,WAAW;AAAA,MACV;AAAA,MACA,EAAE,SAAS,mBAAmB,OAAO,aAAa,mBAAmB;AAAA,IACtE;AAAA,IACA,SAAS,CAAC,oBAAoB,mBAAmB,KAAK;AAAA,EACvD,CAAC;AAAA,GACY;",
|
|
13
|
+
"debugId": "201F91F73B0D621064756E2164756E21",
|
|
14
|
+
"names": []
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexusts/health",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Health check endpoints (live, ready, startup)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "bun run ../../build.ts"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"nexusts",
|
|
24
|
+
"framework",
|
|
25
|
+
"bun"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@nexusts/core": "^0.7.0"
|
|
30
|
+
}
|
|
31
|
+
}
|