@omnitron-dev/titan-health 0.1.1

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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/health.indicator.d.ts +29 -0
  4. package/dist/health.indicator.d.ts.map +1 -0
  5. package/dist/health.indicator.js +136 -0
  6. package/dist/health.indicator.js.map +1 -0
  7. package/dist/health.module.d.ts +9 -0
  8. package/dist/health.module.d.ts.map +1 -0
  9. package/dist/health.module.js +302 -0
  10. package/dist/health.module.js.map +1 -0
  11. package/dist/health.rpc-service.d.ts +56 -0
  12. package/dist/health.rpc-service.d.ts.map +1 -0
  13. package/dist/health.rpc-service.js +138 -0
  14. package/dist/health.rpc-service.js.map +1 -0
  15. package/dist/health.service.d.ts +28 -0
  16. package/dist/health.service.d.ts.map +1 -0
  17. package/dist/health.service.js +182 -0
  18. package/dist/health.service.js.map +1 -0
  19. package/dist/health.tokens.d.ts +12 -0
  20. package/dist/health.tokens.d.ts.map +1 -0
  21. package/dist/health.tokens.js +10 -0
  22. package/dist/health.tokens.js.map +1 -0
  23. package/dist/health.types.d.ts +103 -0
  24. package/dist/health.types.d.ts.map +1 -0
  25. package/dist/health.types.js +2 -0
  26. package/dist/health.types.js.map +1 -0
  27. package/dist/index.d.ts +9 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +8 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/indicators/database.indicator.d.ts +25 -0
  32. package/dist/indicators/database.indicator.d.ts.map +1 -0
  33. package/dist/indicators/database.indicator.js +66 -0
  34. package/dist/indicators/database.indicator.js.map +1 -0
  35. package/dist/indicators/disk.indicator.d.ts +16 -0
  36. package/dist/indicators/disk.indicator.d.ts.map +1 -0
  37. package/dist/indicators/disk.indicator.js +159 -0
  38. package/dist/indicators/disk.indicator.js.map +1 -0
  39. package/dist/indicators/event-loop.indicator.d.ts +27 -0
  40. package/dist/indicators/event-loop.indicator.d.ts.map +1 -0
  41. package/dist/indicators/event-loop.indicator.js +150 -0
  42. package/dist/indicators/event-loop.indicator.js.map +1 -0
  43. package/dist/indicators/index.d.ts +6 -0
  44. package/dist/indicators/index.d.ts.map +1 -0
  45. package/dist/indicators/index.js +6 -0
  46. package/dist/indicators/index.js.map +1 -0
  47. package/dist/indicators/memory.indicator.d.ts +13 -0
  48. package/dist/indicators/memory.indicator.d.ts.map +1 -0
  49. package/dist/indicators/memory.indicator.js +103 -0
  50. package/dist/indicators/memory.indicator.js.map +1 -0
  51. package/dist/indicators/redis.indicator.d.ts +26 -0
  52. package/dist/indicators/redis.indicator.d.ts.map +1 -0
  53. package/dist/indicators/redis.indicator.js +101 -0
  54. package/dist/indicators/redis.indicator.js.map +1 -0
  55. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 LuxQuant
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @omnitron-dev/titan-health
2
+
3
+ > Health check module for the Titan framework
4
+
5
+ Part of the [Omni](../../README.md) monorepo — Fullstack Type-Safe RPC Framework.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @omnitron-dev/titan-health
11
+ ```
12
+
13
+ ## Overview
14
+
15
+ Extensible health check system for Titan applications. Register custom health indicators (database, Redis, external APIs) and expose aggregated health status via RPC or HTTP endpoints.
16
+
17
+ ## License
18
+
19
+ MIT
@@ -0,0 +1,29 @@
1
+ import type { HealthStatus, HealthIndicatorResult, IHealthIndicator } from './health.types.js';
2
+ export declare abstract class HealthIndicator implements IHealthIndicator {
3
+ abstract readonly name: string;
4
+ abstract check(): Promise<HealthIndicatorResult>;
5
+ protected healthy(message?: string, details?: Record<string, unknown>): HealthIndicatorResult;
6
+ protected degraded(message?: string, details?: Record<string, unknown>): HealthIndicatorResult;
7
+ protected unhealthy(message?: string, details?: Record<string, unknown>, error?: Error): HealthIndicatorResult;
8
+ protected createResultFromCondition(isHealthy: boolean, healthyMessage?: string, unhealthyMessage?: string, details?: Record<string, unknown>): HealthIndicatorResult;
9
+ protected createResult(status: HealthStatus, message?: string, details?: Record<string, unknown>): HealthIndicatorResult;
10
+ protected withLatency<T>(operation: () => Promise<T>): Promise<{
11
+ result: T;
12
+ latency: number;
13
+ }>;
14
+ protected withTimeout<T>(operation: () => Promise<T>, timeoutMs: number, timeoutMessage?: string): Promise<T>;
15
+ isHealthy(result?: HealthIndicatorResult): boolean;
16
+ isDegraded(result?: HealthIndicatorResult): boolean;
17
+ isUnhealthy(result?: HealthIndicatorResult): boolean;
18
+ protected getStatusSeverity(status: HealthStatus): number;
19
+ protected getWorstStatus(statuses: HealthStatus[]): HealthStatus;
20
+ }
21
+ export declare class CompositeHealthIndicator extends HealthIndicator {
22
+ readonly name: string;
23
+ private indicators;
24
+ constructor(name: string, indicators?: IHealthIndicator[]);
25
+ addIndicator(indicator: IHealthIndicator): this;
26
+ removeIndicator(name: string): boolean;
27
+ check(): Promise<HealthIndicatorResult>;
28
+ }
29
+ //# sourceMappingURL=health.indicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.indicator.d.ts","sourceRoot":"","sources":["../src/health.indicator.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA0B/F,8BAAsB,eAAgB,YAAW,gBAAgB;IAK/D,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAM/B,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAKhD,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB;IAO7F,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB;IAO9F,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,qBAAqB;IAe9G,SAAS,CAAC,yBAAyB,CACjC,SAAS,EAAE,OAAO,EAClB,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,qBAAqB;IAOxB,SAAS,CAAC,YAAY,CACpB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,qBAAqB;cAYR,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;cAUpF,WAAW,CAAC,CAAC,EAC3B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,SAAS,EAAE,MAAM,EACjB,cAAc,SAA2B,GACxC,OAAO,CAAC,CAAC,CAAC;IAqBb,SAAS,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO;IAOlD,UAAU,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO;IAOnD,WAAW,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO;IAOpD,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM;IAgBzD,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY;CAQjE;AAcD,qBAAa,wBAAyB,SAAQ,eAAe;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,UAAU,CAAqB;gBAE3B,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,gBAAgB,EAAO;IAS7D,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAQ/C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAYhC,KAAK,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAyC9C"}
@@ -0,0 +1,136 @@
1
+ export class HealthIndicator {
2
+ healthy(message, details) {
3
+ return this.createResult('healthy', message, details);
4
+ }
5
+ degraded(message, details) {
6
+ return this.createResult('degraded', message, details);
7
+ }
8
+ unhealthy(message, details, error) {
9
+ const result = this.createResult('unhealthy', message, details);
10
+ if (error) {
11
+ result.error = {
12
+ message: error.message,
13
+ code: error.code,
14
+ stack: process.env['NODE_ENV'] !== 'production' ? error.stack : undefined,
15
+ };
16
+ }
17
+ return result;
18
+ }
19
+ createResultFromCondition(isHealthy, healthyMessage, unhealthyMessage, details) {
20
+ return isHealthy ? this.healthy(healthyMessage, details) : this.unhealthy(unhealthyMessage, details);
21
+ }
22
+ createResult(status, message, details) {
23
+ return {
24
+ status,
25
+ message,
26
+ details,
27
+ timestamp: new Date(),
28
+ };
29
+ }
30
+ async withLatency(operation) {
31
+ const start = Date.now();
32
+ const result = await operation();
33
+ const latency = Date.now() - start;
34
+ return { result, latency };
35
+ }
36
+ async withTimeout(operation, timeoutMs, timeoutMessage = 'Health check timed out') {
37
+ return new Promise((resolve, reject) => {
38
+ const timer = setTimeout(() => {
39
+ reject(new Error(timeoutMessage));
40
+ }, timeoutMs);
41
+ operation()
42
+ .then((result) => {
43
+ clearTimeout(timer);
44
+ resolve(result);
45
+ })
46
+ .catch((error) => {
47
+ clearTimeout(timer);
48
+ reject(error);
49
+ });
50
+ });
51
+ }
52
+ isHealthy(result) {
53
+ return result?.status === 'healthy';
54
+ }
55
+ isDegraded(result) {
56
+ return result?.status === 'degraded';
57
+ }
58
+ isUnhealthy(result) {
59
+ return result?.status === 'unhealthy';
60
+ }
61
+ getStatusSeverity(status) {
62
+ switch (status) {
63
+ case 'healthy':
64
+ return 0;
65
+ case 'degraded':
66
+ return 1;
67
+ case 'unhealthy':
68
+ return 2;
69
+ default:
70
+ return 2;
71
+ }
72
+ }
73
+ getWorstStatus(statuses) {
74
+ if (statuses.length === 0)
75
+ return 'healthy';
76
+ return statuses.reduce((worst, current) => (this.getStatusSeverity(current) > this.getStatusSeverity(worst) ? current : worst), 'healthy');
77
+ }
78
+ }
79
+ export class CompositeHealthIndicator extends HealthIndicator {
80
+ constructor(name, indicators = []) {
81
+ super();
82
+ this.name = name;
83
+ this.indicators = indicators;
84
+ }
85
+ addIndicator(indicator) {
86
+ this.indicators.push(indicator);
87
+ return this;
88
+ }
89
+ removeIndicator(name) {
90
+ const index = this.indicators.findIndex((i) => i.name === name);
91
+ if (index >= 0) {
92
+ this.indicators.splice(index, 1);
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ async check() {
98
+ const start = Date.now();
99
+ const results = await Promise.allSettled(this.indicators.map((i) => i.check()));
100
+ const indicatorResults = {};
101
+ const statuses = [];
102
+ results.forEach((result, index) => {
103
+ const indicator = this.indicators[index];
104
+ if (!indicator)
105
+ return;
106
+ if (result.status === 'fulfilled') {
107
+ indicatorResults[indicator.name] = result.value;
108
+ statuses.push(result.value.status);
109
+ }
110
+ else {
111
+ indicatorResults[indicator.name] = {
112
+ status: 'unhealthy',
113
+ message: result.reason?.message || 'Health check failed',
114
+ error: {
115
+ message: result.reason?.message || 'Unknown error',
116
+ },
117
+ timestamp: new Date(),
118
+ };
119
+ statuses.push('unhealthy');
120
+ }
121
+ });
122
+ const overallStatus = this.getWorstStatus(statuses);
123
+ const latency = Date.now() - start;
124
+ return {
125
+ status: overallStatus,
126
+ message: 'Composite check of ' + this.indicators.length + ' indicators',
127
+ details: {
128
+ indicators: indicatorResults,
129
+ indicatorCount: this.indicators.length,
130
+ },
131
+ latency,
132
+ timestamp: new Date(),
133
+ };
134
+ }
135
+ }
136
+ //# sourceMappingURL=health.indicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.indicator.js","sourceRoot":"","sources":["../src/health.indicator.ts"],"names":[],"mappings":"AAmCA,MAAM,OAAgB,eAAe;IAgBzB,OAAO,CAAC,OAAgB,EAAE,OAAiC;QACnE,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAKS,QAAQ,CAAC,OAAgB,EAAE,OAAiC;QACpE,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAKS,SAAS,CAAC,OAAgB,EAAE,OAAiC,EAAE,KAAa;QACpF,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC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C,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACrC,CAAC;iBAAM,CAAC;gBACN,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;oBACjC,MAAM,EAAE,WAAW;oBACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,qBAAqB;oBACxD,KAAK,EAAE;wBACL,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,eAAe;qBACnD;oBACD,SAAS,EAAE,IAAI,IAAI,EAAE;iBACtB,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAEnC,OAAO;YACL,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,aAAa;YACvE,OAAO,EAAE;gBACP,UAAU,EAAE,gBAAgB;gBAC5B,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;aACvC;YACD,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { DynamicModule } from '@omnitron-dev/titan/nexus';
2
+ import type { HealthModuleOptions, HealthModuleAsyncOptions, IHealthIndicator } from './health.types.js';
3
+ export declare class TitanHealthModule {
4
+ name: string;
5
+ static forRoot(options?: HealthModuleOptions): DynamicModule;
6
+ static forRootAsync(options: HealthModuleAsyncOptions): DynamicModule;
7
+ static forFeature(indicators: Array<new (...args: any[]) => IHealthIndicator>): DynamicModule;
8
+ }
9
+ //# sourceMappingURL=health.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.module.d.ts","sourceRoot":"","sources":["../src/health.module.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAgD,MAAM,2BAA2B,CAAC;AAmB7G,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAkEzG,qBACa,iBAAiB;IAC5B,IAAI,SAAuB;IAK3B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,mBAAwB,GAAG,aAAa;IA0KhE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;IAmKrE,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,gBAAgB,CAAC,GAAG,aAAa;CA0B9F"}
@@ -0,0 +1,302 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var TitanHealthModule_1;
8
+ import { Module } from '@omnitron-dev/titan/decorators';
9
+ import { HealthService } from './health.service.js';
10
+ import { HealthRpcService } from './health.rpc-service.js';
11
+ import { MemoryHealthIndicator } from './indicators/memory.indicator.js';
12
+ import { EventLoopHealthIndicator } from './indicators/event-loop.indicator.js';
13
+ import { DiskHealthIndicator } from './indicators/disk.indicator.js';
14
+ import { DatabaseHealthIndicator } from './indicators/database.indicator.js';
15
+ import { RedisHealthIndicator } from './indicators/redis.indicator.js';
16
+ import { HEALTH_SERVICE_TOKEN, HEALTH_MODULE_OPTIONS_TOKEN, HEALTH_RPC_SERVICE_TOKEN, MEMORY_HEALTH_INDICATOR_TOKEN, EVENT_LOOP_HEALTH_INDICATOR_TOKEN, DISK_HEALTH_INDICATOR_TOKEN, DATABASE_HEALTH_INDICATOR_TOKEN, REDIS_HEALTH_INDICATOR_TOKEN, } from './health.tokens.js';
17
+ let TitanHealthModule = TitanHealthModule_1 = class TitanHealthModule {
18
+ constructor() {
19
+ this.name = 'TitanHealthModule';
20
+ }
21
+ static forRoot(options = {}) {
22
+ const providers = [];
23
+ const healthService = new HealthService(options);
24
+ providers.push([
25
+ HEALTH_MODULE_OPTIONS_TOKEN,
26
+ {
27
+ useValue: options,
28
+ },
29
+ ]);
30
+ providers.push([
31
+ HEALTH_SERVICE_TOKEN,
32
+ {
33
+ useValue: healthService,
34
+ },
35
+ ]);
36
+ providers.push([
37
+ HealthService,
38
+ {
39
+ useValue: healthService,
40
+ },
41
+ ]);
42
+ if (options.enableMemoryIndicator !== false) {
43
+ const memoryIndicator = new MemoryHealthIndicator(options.memoryThresholds);
44
+ healthService.registerIndicator(memoryIndicator);
45
+ providers.push([
46
+ MEMORY_HEALTH_INDICATOR_TOKEN,
47
+ {
48
+ useValue: memoryIndicator,
49
+ },
50
+ ]);
51
+ }
52
+ if (options.enableEventLoopIndicator !== false) {
53
+ const eventLoopIndicator = new EventLoopHealthIndicator(options.eventLoopThresholds);
54
+ healthService.registerIndicator(eventLoopIndicator);
55
+ providers.push([
56
+ EVENT_LOOP_HEALTH_INDICATOR_TOKEN,
57
+ {
58
+ useValue: eventLoopIndicator,
59
+ },
60
+ ]);
61
+ }
62
+ if (options.enableDiskIndicator === true) {
63
+ const diskIndicator = new DiskHealthIndicator(options.diskThresholds);
64
+ healthService.registerIndicator(diskIndicator);
65
+ providers.push([
66
+ DISK_HEALTH_INDICATOR_TOKEN,
67
+ {
68
+ useValue: diskIndicator,
69
+ },
70
+ ]);
71
+ }
72
+ if (options.enableDatabaseIndicator === true) {
73
+ const databaseIndicator = new DatabaseHealthIndicator(options.databaseConnection, options.databaseOptions);
74
+ healthService.registerIndicator(databaseIndicator);
75
+ providers.push([
76
+ DATABASE_HEALTH_INDICATOR_TOKEN,
77
+ {
78
+ useValue: databaseIndicator,
79
+ },
80
+ ]);
81
+ }
82
+ if (options.enableRedisIndicator === true) {
83
+ const redisIndicator = new RedisHealthIndicator(options.redisClient, options.redisOptions);
84
+ healthService.registerIndicator(redisIndicator);
85
+ providers.push([
86
+ REDIS_HEALTH_INDICATOR_TOKEN,
87
+ {
88
+ useValue: redisIndicator,
89
+ },
90
+ ]);
91
+ }
92
+ if (options.indicators) {
93
+ for (const IndicatorClass of options.indicators) {
94
+ const indicator = new IndicatorClass();
95
+ healthService.registerIndicator(indicator);
96
+ }
97
+ }
98
+ if (options.enableRpcService !== false) {
99
+ const healthRpcService = new HealthRpcService();
100
+ healthRpcService.setHealthService(healthService);
101
+ if (options.version) {
102
+ healthRpcService.setVersion(options.version);
103
+ }
104
+ providers.push([
105
+ HEALTH_RPC_SERVICE_TOKEN,
106
+ {
107
+ useValue: healthRpcService,
108
+ },
109
+ ]);
110
+ providers.push([
111
+ HealthRpcService,
112
+ {
113
+ useValue: healthRpcService,
114
+ },
115
+ ]);
116
+ }
117
+ const exports = [HEALTH_SERVICE_TOKEN, HEALTH_MODULE_OPTIONS_TOKEN, HealthService];
118
+ if (options.enableMemoryIndicator !== false) {
119
+ exports.push(MEMORY_HEALTH_INDICATOR_TOKEN);
120
+ }
121
+ if (options.enableEventLoopIndicator !== false) {
122
+ exports.push(EVENT_LOOP_HEALTH_INDICATOR_TOKEN);
123
+ }
124
+ if (options.enableDiskIndicator === true) {
125
+ exports.push(DISK_HEALTH_INDICATOR_TOKEN);
126
+ }
127
+ if (options.enableDatabaseIndicator === true) {
128
+ exports.push(DATABASE_HEALTH_INDICATOR_TOKEN);
129
+ }
130
+ if (options.enableRedisIndicator === true) {
131
+ exports.push(REDIS_HEALTH_INDICATOR_TOKEN);
132
+ }
133
+ if (options.enableRpcService !== false) {
134
+ exports.push(HEALTH_RPC_SERVICE_TOKEN);
135
+ exports.push(HealthRpcService);
136
+ }
137
+ const result = {
138
+ module: TitanHealthModule_1,
139
+ providers,
140
+ exports,
141
+ };
142
+ if (options.isGlobal) {
143
+ result.global = true;
144
+ }
145
+ return result;
146
+ }
147
+ static forRootAsync(options) {
148
+ const providers = [];
149
+ if (options.useFactory) {
150
+ providers.push([
151
+ HEALTH_MODULE_OPTIONS_TOKEN,
152
+ {
153
+ useFactory: options.useFactory,
154
+ inject: options.inject || [],
155
+ },
156
+ ]);
157
+ }
158
+ providers.push([
159
+ HEALTH_SERVICE_TOKEN,
160
+ {
161
+ useFactory: async (moduleOptions) => {
162
+ const healthService = new HealthService(moduleOptions);
163
+ if (moduleOptions.enableMemoryIndicator !== false) {
164
+ healthService.registerIndicator(new MemoryHealthIndicator(moduleOptions.memoryThresholds));
165
+ }
166
+ if (moduleOptions.enableEventLoopIndicator !== false) {
167
+ healthService.registerIndicator(new EventLoopHealthIndicator(moduleOptions.eventLoopThresholds));
168
+ }
169
+ if (moduleOptions.enableDiskIndicator === true) {
170
+ healthService.registerIndicator(new DiskHealthIndicator(moduleOptions.diskThresholds));
171
+ }
172
+ if (moduleOptions.enableDatabaseIndicator === true) {
173
+ healthService.registerIndicator(new DatabaseHealthIndicator(moduleOptions.databaseConnection, moduleOptions.databaseOptions));
174
+ }
175
+ if (moduleOptions.enableRedisIndicator === true) {
176
+ healthService.registerIndicator(new RedisHealthIndicator(moduleOptions.redisClient, moduleOptions.redisOptions));
177
+ }
178
+ if (moduleOptions.indicators) {
179
+ for (const IndicatorClass of moduleOptions.indicators) {
180
+ healthService.registerIndicator(new IndicatorClass());
181
+ }
182
+ }
183
+ return healthService;
184
+ },
185
+ inject: [HEALTH_MODULE_OPTIONS_TOKEN],
186
+ },
187
+ ]);
188
+ providers.push([
189
+ HealthService,
190
+ {
191
+ useFactory: (healthService) => healthService,
192
+ inject: [HEALTH_SERVICE_TOKEN],
193
+ },
194
+ ]);
195
+ providers.push([
196
+ HEALTH_RPC_SERVICE_TOKEN,
197
+ {
198
+ useFactory: (healthService, moduleOptions) => {
199
+ const rpcService = new HealthRpcService();
200
+ rpcService.setHealthService(healthService);
201
+ if (moduleOptions.version) {
202
+ rpcService.setVersion(moduleOptions.version);
203
+ }
204
+ return rpcService;
205
+ },
206
+ inject: [HEALTH_SERVICE_TOKEN, HEALTH_MODULE_OPTIONS_TOKEN],
207
+ },
208
+ ]);
209
+ providers.push([
210
+ HealthRpcService,
211
+ {
212
+ useFactory: (rpcService) => rpcService,
213
+ inject: [HEALTH_RPC_SERVICE_TOKEN],
214
+ },
215
+ ]);
216
+ providers.push([
217
+ MEMORY_HEALTH_INDICATOR_TOKEN,
218
+ {
219
+ useFactory: (healthService) => healthService.getIndicator('memory'),
220
+ inject: [HEALTH_SERVICE_TOKEN],
221
+ },
222
+ ]);
223
+ providers.push([
224
+ EVENT_LOOP_HEALTH_INDICATOR_TOKEN,
225
+ {
226
+ useFactory: (healthService) => healthService.getIndicator('event-loop'),
227
+ inject: [HEALTH_SERVICE_TOKEN],
228
+ },
229
+ ]);
230
+ providers.push([
231
+ DISK_HEALTH_INDICATOR_TOKEN,
232
+ {
233
+ useFactory: (healthService) => healthService.getIndicator('disk'),
234
+ inject: [HEALTH_SERVICE_TOKEN],
235
+ },
236
+ ]);
237
+ providers.push([
238
+ DATABASE_HEALTH_INDICATOR_TOKEN,
239
+ {
240
+ useFactory: (healthService) => healthService.getIndicator('database'),
241
+ inject: [HEALTH_SERVICE_TOKEN],
242
+ },
243
+ ]);
244
+ providers.push([
245
+ REDIS_HEALTH_INDICATOR_TOKEN,
246
+ {
247
+ useFactory: (healthService) => healthService.getIndicator('redis'),
248
+ inject: [HEALTH_SERVICE_TOKEN],
249
+ },
250
+ ]);
251
+ const exports = [
252
+ HEALTH_SERVICE_TOKEN,
253
+ HEALTH_MODULE_OPTIONS_TOKEN,
254
+ HEALTH_RPC_SERVICE_TOKEN,
255
+ HealthService,
256
+ HealthRpcService,
257
+ MEMORY_HEALTH_INDICATOR_TOKEN,
258
+ EVENT_LOOP_HEALTH_INDICATOR_TOKEN,
259
+ DISK_HEALTH_INDICATOR_TOKEN,
260
+ DATABASE_HEALTH_INDICATOR_TOKEN,
261
+ REDIS_HEALTH_INDICATOR_TOKEN,
262
+ ];
263
+ const result = {
264
+ module: TitanHealthModule_1,
265
+ imports: options.imports || [],
266
+ providers,
267
+ exports,
268
+ };
269
+ if (options.isGlobal) {
270
+ result.global = true;
271
+ }
272
+ return result;
273
+ }
274
+ static forFeature(indicators) {
275
+ const providers = [];
276
+ providers.push([
277
+ 'HEALTH_FEATURE_INIT',
278
+ {
279
+ useFactory: (healthService) => {
280
+ for (const IndicatorClass of indicators) {
281
+ const indicator = new IndicatorClass();
282
+ if (!healthService.hasIndicator(indicator.name)) {
283
+ healthService.registerIndicator(indicator);
284
+ }
285
+ }
286
+ return true;
287
+ },
288
+ inject: [HEALTH_SERVICE_TOKEN],
289
+ },
290
+ ]);
291
+ return {
292
+ module: TitanHealthModule_1,
293
+ providers,
294
+ exports: [],
295
+ };
296
+ }
297
+ };
298
+ TitanHealthModule = TitanHealthModule_1 = __decorate([
299
+ Module()
300
+ ], TitanHealthModule);
301
+ export { TitanHealthModule };
302
+ //# sourceMappingURL=health.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.module.js","sourceRoot":"","sources":["../src/health.module.ts"],"names":[],"mappings":";;;;;;;AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,mBAAmB,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,CAAC;IACJ,CAAC;CACF,CAAA;AA7WY,iBAAiB;IAD7B,MAAM,EAAE;GACI,iBAAiB,CA6W7B"}
@@ -0,0 +1,56 @@
1
+ import type { HealthService } from './health.service.js';
2
+ import type { HealthIndicatorResult, HealthStatus } from './health.types.js';
3
+ export interface LivenessResponse {
4
+ status: 'up' | 'down';
5
+ timestamp: string;
6
+ }
7
+ export interface ReadinessResponse {
8
+ status: HealthStatus;
9
+ timestamp: string;
10
+ checks?: Record<string, {
11
+ status: HealthStatus;
12
+ message?: string;
13
+ }>;
14
+ }
15
+ export interface HealthResponse {
16
+ status: HealthStatus;
17
+ timestamp: string;
18
+ uptime: number;
19
+ version?: string;
20
+ indicators: Record<string, HealthIndicatorResult>;
21
+ totalLatency?: number;
22
+ }
23
+ export interface IndicatorResponse {
24
+ name: string;
25
+ result: HealthIndicatorResult;
26
+ }
27
+ export interface UptimeResponse {
28
+ uptime: {
29
+ ms: number;
30
+ formatted: string;
31
+ days: number;
32
+ hours: number;
33
+ minutes: number;
34
+ seconds: number;
35
+ };
36
+ timestamp: string;
37
+ }
38
+ export declare class HealthRpcService {
39
+ private healthService;
40
+ private version?;
41
+ setHealthService(healthService: HealthService): void;
42
+ setVersion(version: string): void;
43
+ check(): Promise<HealthResponse>;
44
+ live(): Promise<LivenessResponse>;
45
+ ready(): Promise<ReadinessResponse>;
46
+ checkIndicator(name: string): Promise<IndicatorResponse>;
47
+ listIndicators(): Promise<{
48
+ indicators: string[];
49
+ count: number;
50
+ }>;
51
+ uptime(): Promise<UptimeResponse>;
52
+ isHealthy(): Promise<{
53
+ healthy: boolean;
54
+ }>;
55
+ }
56
+ //# sourceMappingURL=health.rpc-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.rpc-service.d.ts","sourceRoot":"","sources":["../src/health.rpc-service.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAA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