nest-healthkit 0.1.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.
Files changed (47) hide show
  1. package/README.md +177 -0
  2. package/dist/decorators/health-check.decorator.d.ts +2 -0
  3. package/dist/decorators/health-check.decorator.js +10 -0
  4. package/dist/decorators/health-check.decorator.js.map +1 -0
  5. package/dist/healthkit.constants.d.ts +2 -0
  6. package/dist/healthkit.constants.js +6 -0
  7. package/dist/healthkit.constants.js.map +1 -0
  8. package/dist/healthkit.controller.d.ts +30 -0
  9. package/dist/healthkit.controller.js +154 -0
  10. package/dist/healthkit.controller.js.map +1 -0
  11. package/dist/healthkit.interfaces.d.ts +69 -0
  12. package/dist/healthkit.interfaces.js +3 -0
  13. package/dist/healthkit.interfaces.js.map +1 -0
  14. package/dist/healthkit.module.d.ts +11 -0
  15. package/dist/healthkit.module.js +220 -0
  16. package/dist/healthkit.module.js.map +1 -0
  17. package/dist/healthkit.service.d.ts +29 -0
  18. package/dist/healthkit.service.js +226 -0
  19. package/dist/healthkit.service.js.map +1 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.js +12 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/indicators/base.indicator.d.ts +4 -0
  24. package/dist/indicators/base.indicator.js +27 -0
  25. package/dist/indicators/base.indicator.js.map +1 -0
  26. package/dist/indicators/disk.indicator.d.ts +18 -0
  27. package/dist/indicators/disk.indicator.js +125 -0
  28. package/dist/indicators/disk.indicator.js.map +1 -0
  29. package/dist/indicators/http.indicator.d.ts +9 -0
  30. package/dist/indicators/http.indicator.js +104 -0
  31. package/dist/indicators/http.indicator.js.map +1 -0
  32. package/dist/indicators/memory.indicator.d.ts +8 -0
  33. package/dist/indicators/memory.indicator.js +50 -0
  34. package/dist/indicators/memory.indicator.js.map +1 -0
  35. package/dist/indicators/prisma.indicator.d.ts +14 -0
  36. package/dist/indicators/prisma.indicator.js +90 -0
  37. package/dist/indicators/prisma.indicator.js.map +1 -0
  38. package/dist/indicators/redis.indicator.d.ts +12 -0
  39. package/dist/indicators/redis.indicator.js +105 -0
  40. package/dist/indicators/redis.indicator.js.map +1 -0
  41. package/dist/indicators/typeorm.indicator.d.ts +12 -0
  42. package/dist/indicators/typeorm.indicator.js +123 -0
  43. package/dist/indicators/typeorm.indicator.js.map +1 -0
  44. package/dist/ui/dashboard.html.d.ts +2 -0
  45. package/dist/ui/dashboard.html.js +71 -0
  46. package/dist/ui/dashboard.html.js.map +1 -0
  47. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # nest-healthkit
2
+
3
+ ## Why nest-healthkit
4
+ `nest-healthkit` removes the manual controller and indicator wiring that teams usually build around NestJS health endpoints. It keeps the flexibility of custom checks while shipping a batteries-included readiness and liveness setup. It complements `@nestjs/terminus` instead of replacing it.
5
+
6
+ ## Installation
7
+ ```bash
8
+ npm install nest-healthkit
9
+ ```
10
+
11
+ ## Quick Start
12
+ ```ts
13
+ import { Module } from '@nestjs/common';
14
+ import { HealthkitModule } from 'nest-healthkit';
15
+
16
+ import { PrismaService } from './prisma.service';
17
+
18
+ @Module({
19
+ imports: [
20
+ HealthkitModule.forRoot({
21
+ ui: true,
22
+ cacheTtl: 5000,
23
+ indicators: {
24
+ prisma: { prismaToken: PrismaService, name: 'postgres' },
25
+ redis: { redisToken: 'REDIS_CLIENT' },
26
+ memory: { heapThreshold: 400 * 1024 * 1024 },
27
+ },
28
+ }),
29
+ ],
30
+ })
31
+ export class AppModule {}
32
+ ```
33
+
34
+ ## Configuration Reference
35
+ | Option | Type | Default | Description |
36
+ |---|---|---|---|
37
+ | `path` | `string` | `'health'` | Route prefix used for all health endpoints. |
38
+ | `ui` | `boolean` | `false` | Enables the HTML dashboard at `/{path}/ui`. |
39
+ | `authHeaders` | `Record<string, string>` | `undefined` | Required request headers for all health endpoints. |
40
+ | `timeout` | `number` | `5000` | Per-check timeout in milliseconds. |
41
+ | `cacheTtl` | `number` | `0` | Result cache TTL in milliseconds. |
42
+ | `indicators.prisma` | `PrismaIndicatorOptions` | `undefined` | Enables the Prisma indicator. |
43
+ | `indicators.typeorm` | `TypeOrmIndicatorOptions` | `undefined` | Enables the TypeORM indicator. |
44
+ | `indicators.redis` | `RedisIndicatorOptions` | `undefined` | Enables the Redis indicator. |
45
+ | `indicators.http` | `HttpIndicatorOptions \| HttpIndicatorOptions[]` | `undefined` | Enables one or more HTTP checks. |
46
+ | `indicators.memory` | `MemoryIndicatorOptions` | `undefined` | Enables the memory indicator. |
47
+ | `indicators.disk` | `DiskIndicatorOptions` | `undefined` | Enables the disk indicator. |
48
+
49
+ ## Built-in Indicators
50
+ ### Prisma
51
+ ```ts
52
+ HealthkitModule.forRoot({
53
+ indicators: {
54
+ prisma: { prismaToken: PrismaService, name: 'postgres' },
55
+ },
56
+ });
57
+ ```
58
+
59
+ ### TypeORM
60
+ ```ts
61
+ HealthkitModule.forRoot({
62
+ indicators: {
63
+ typeorm: { connectionName: 'default', name: 'typeorm' },
64
+ },
65
+ });
66
+ ```
67
+
68
+ ### Redis
69
+ ```ts
70
+ HealthkitModule.forRoot({
71
+ indicators: {
72
+ redis: { redisToken: 'REDIS_CLIENT', name: 'redis' },
73
+ },
74
+ });
75
+ ```
76
+
77
+ ### HTTP
78
+ ```ts
79
+ HealthkitModule.forRoot({
80
+ indicators: {
81
+ http: [
82
+ { url: 'https://api.example.com/health', name: 'public-api' },
83
+ { url: 'https://internal.example.com/status', name: 'internal-api', expectedStatus: 204 },
84
+ ],
85
+ },
86
+ });
87
+ ```
88
+
89
+ ### Memory
90
+ ```ts
91
+ HealthkitModule.forRoot({
92
+ indicators: {
93
+ memory: {
94
+ heapThreshold: 300 * 1024 * 1024,
95
+ heapCritical: 500 * 1024 * 1024,
96
+ },
97
+ },
98
+ });
99
+ ```
100
+
101
+ ### Disk
102
+ ```ts
103
+ HealthkitModule.forRoot({
104
+ indicators: {
105
+ disk: {
106
+ path: '/',
107
+ thresholdPercent: 0.8,
108
+ criticalPercent: 0.95,
109
+ },
110
+ },
111
+ });
112
+ ```
113
+
114
+ ## Custom Checks with `@RegisterHealthCheck()`
115
+ ```ts
116
+ import { Injectable } from '@nestjs/common';
117
+ import {
118
+ HealthIndicatorResult,
119
+ RegisterHealthCheck,
120
+ } from 'nest-healthkit';
121
+
122
+ @Injectable()
123
+ export class PaymentHealthIndicator {
124
+ @RegisterHealthCheck('stripe')
125
+ async checkStripe(): Promise<HealthIndicatorResult> {
126
+ return {
127
+ name: 'stripe',
128
+ status: 'up',
129
+ durationMs: 0,
130
+ };
131
+ }
132
+ }
133
+ ```
134
+
135
+ Prototype methods are discovered automatically. Arrow-function class properties are not scanned because Nest's metadata scanner only walks the prototype.
136
+
137
+ ## Endpoints
138
+ | Method | Route | Description | Response |
139
+ |---|---|---|---|
140
+ | `GET` | `/{path}/live` | Process liveness check | `{ status, timestamp, uptime, checks }` |
141
+ | `GET` | `/{path}/ready` | Readiness check for all registered indicators | `{ status, timestamp, uptime, checks }` |
142
+ | `GET` | `/{path}` | Alias for readiness | `{ status, timestamp, uptime, checks }` |
143
+ | `GET` | `/{path}/ui` | Optional HTML dashboard | HTML when enabled, `{ error: 'Not found' }` when disabled |
144
+
145
+ `status: 'up'` and `status: 'degraded'` return HTTP `200`. `status: 'down'` returns HTTP `503`.
146
+
147
+ ## Dashboard UI
148
+ Enable the dashboard with `ui: true` to serve a lightweight dark-mode HTML view at `/{path}/ui`. The page shows overall status, uptime, timestamp, and a per-check table, and it auto-refreshes every 30 seconds. Think of it as an operator-friendly snapshot rather than a full monitoring frontend.
149
+
150
+ ## Compatibility
151
+ | Concern | Requirement |
152
+ |---|---|
153
+ | NestJS version | `^9.0.0` and `^10.0.0` |
154
+ | HTTP adapter | Express and Fastify |
155
+ | TypeScript | `^5.0.0` |
156
+ | Node.js | `^18.0.0` |
157
+ | Prisma version | `^4.x` and `^5.x` |
158
+ | TypeORM version | `^0.2.x` and `^0.3.x` |
159
+ | ioredis version | `^4.x` and `^5.x` |
160
+ | ESM/CJS | CJS output only |
161
+
162
+ ## Custom Indicators (advanced)
163
+ ```ts
164
+ import { BaseIndicator, HealthCheckFn } from 'nest-healthkit';
165
+
166
+ class StripeIndicator extends BaseIndicator {
167
+ getCheck(): HealthCheckFn {
168
+ return async () =>
169
+ this.measure('stripe', async () => {
170
+ await Promise.resolve();
171
+ return { region: 'us-east-1' };
172
+ });
173
+ }
174
+ }
175
+ ```
176
+
177
+ Extend `BaseIndicator` when you want a reusable indicator with consistent duration measurement and error handling, then register the returned `HealthCheckFn` inside your own provider.
@@ -0,0 +1,2 @@
1
+ export declare const HEALTH_CHECK_METADATA = "__healthkit_check__";
2
+ export declare function RegisterHealthCheck(name: string): MethodDecorator;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HEALTH_CHECK_METADATA = void 0;
4
+ exports.RegisterHealthCheck = RegisterHealthCheck;
5
+ const common_1 = require("@nestjs/common");
6
+ exports.HEALTH_CHECK_METADATA = '__healthkit_check__';
7
+ function RegisterHealthCheck(name) {
8
+ return (0, common_1.SetMetadata)(exports.HEALTH_CHECK_METADATA, name);
9
+ }
10
+ //# sourceMappingURL=health-check.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-check.decorator.js","sourceRoot":"","sources":["../../src/decorators/health-check.decorator.ts"],"names":[],"mappings":";;;AAIA,kDAEC;AAND,2CAA6C;AAEhC,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAE3D,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,oBAAW,EAAC,6BAAqB,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const HEALTHKIT_OPTIONS = "HEALTHKIT_OPTIONS";
2
+ export declare const HEALTHKIT_CHECKS_REGISTRY = "HEALTHKIT_CHECKS_REGISTRY";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HEALTHKIT_CHECKS_REGISTRY = exports.HEALTHKIT_OPTIONS = void 0;
4
+ exports.HEALTHKIT_OPTIONS = 'HEALTHKIT_OPTIONS';
5
+ exports.HEALTHKIT_CHECKS_REGISTRY = 'HEALTHKIT_CHECKS_REGISTRY';
6
+ //# sourceMappingURL=healthkit.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthkit.constants.js","sourceRoot":"","sources":["../src/healthkit.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,yBAAyB,GAAG,2BAA2B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { CanActivate } from '@nestjs/common';
2
+ import type { ExecutionContext } from '@nestjs/common';
3
+ import { type HealthCheckResult, type HealthkitModuleOptions } from './healthkit.interfaces';
4
+ import { HealthkitService } from './healthkit.service';
5
+ export declare const HEALTHKIT_CONTROLLER_PATH_READY: unique symbol;
6
+ interface HttpResponseLike {
7
+ code?: (statusCode: number) => unknown;
8
+ header?: (name: string, value: string) => unknown;
9
+ setHeader?: (name: string, value: string) => unknown;
10
+ status?: (statusCode: number) => unknown;
11
+ statusCode?: number;
12
+ }
13
+ export declare class HealthkitAuthGuard implements CanActivate {
14
+ private readonly options;
15
+ constructor(options: HealthkitModuleOptions);
16
+ canActivate(context: ExecutionContext): boolean;
17
+ }
18
+ export declare class HealthkitController {
19
+ private readonly controllerPathReady;
20
+ private readonly healthkitService;
21
+ private readonly options;
22
+ constructor(controllerPathReady: boolean, healthkitService: HealthkitService, options: HealthkitModuleOptions);
23
+ live(response: HttpResponseLike): Promise<HealthCheckResult | Record<string, string>>;
24
+ ready(response: HttpResponseLike): Promise<HealthCheckResult | Record<string, string>>;
25
+ root(response: HttpResponseLike): Promise<HealthCheckResult | Record<string, string>>;
26
+ ui(response: HttpResponseLike): Promise<string | Record<string, string>>;
27
+ private runJsonCheck;
28
+ private handleFailure;
29
+ }
30
+ export {};
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HealthkitController = exports.HealthkitAuthGuard = exports.HEALTHKIT_CONTROLLER_PATH_READY = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const healthkit_constants_1 = require("./healthkit.constants");
18
+ const healthkit_service_1 = require("./healthkit.service");
19
+ const dashboard_html_1 = require("./ui/dashboard.html");
20
+ exports.HEALTHKIT_CONTROLLER_PATH_READY = Symbol('HEALTHKIT_CONTROLLER_PATH_READY');
21
+ let HealthkitAuthGuard = class HealthkitAuthGuard {
22
+ constructor(options) {
23
+ this.options = options;
24
+ }
25
+ canActivate(context) {
26
+ const authHeaders = this.options.authHeaders;
27
+ if (!authHeaders || Object.keys(authHeaders).length === 0) {
28
+ return true;
29
+ }
30
+ const request = context.switchToHttp().getRequest();
31
+ const headers = request?.headers ?? {};
32
+ for (const [headerName, expectedValue] of Object.entries(authHeaders)) {
33
+ const actualValue = headers[headerName.toLowerCase()] ?? headers[headerName];
34
+ const actual = Array.isArray(actualValue) ? actualValue[0] : actualValue;
35
+ if (actual !== expectedValue) {
36
+ throw new common_1.UnauthorizedException({ error: 'Unauthorized' });
37
+ }
38
+ }
39
+ return true;
40
+ }
41
+ };
42
+ exports.HealthkitAuthGuard = HealthkitAuthGuard;
43
+ exports.HealthkitAuthGuard = HealthkitAuthGuard = __decorate([
44
+ (0, common_1.Injectable)(),
45
+ __param(0, (0, common_1.Inject)(healthkit_constants_1.HEALTHKIT_OPTIONS)),
46
+ __metadata("design:paramtypes", [Object])
47
+ ], HealthkitAuthGuard);
48
+ let HealthkitController = class HealthkitController {
49
+ constructor(controllerPathReady, healthkitService, options) {
50
+ this.controllerPathReady = controllerPathReady;
51
+ this.healthkitService = healthkitService;
52
+ this.options = options;
53
+ void this.controllerPathReady;
54
+ }
55
+ async live(response) {
56
+ return this.runJsonCheck(response, () => this.healthkitService.runLiveness());
57
+ }
58
+ async ready(response) {
59
+ return this.runJsonCheck(response, () => this.healthkitService.runReadiness());
60
+ }
61
+ async root(response) {
62
+ return this.runJsonCheck(response, () => this.healthkitService.runAll());
63
+ }
64
+ async ui(response) {
65
+ if (!this.options.ui) {
66
+ setHttpStatus(response, 404);
67
+ return { error: 'Not found' };
68
+ }
69
+ try {
70
+ const result = await this.healthkitService.runAll();
71
+ setHttpStatus(response, result.status === 'down' ? 503 : 200);
72
+ setHeader(response, 'content-type', 'text/html; charset=utf-8');
73
+ return (0, dashboard_html_1.renderDashboard)(result);
74
+ }
75
+ catch (error) {
76
+ return this.handleFailure(response, error);
77
+ }
78
+ }
79
+ async runJsonCheck(response, fn) {
80
+ try {
81
+ const result = await fn();
82
+ setHttpStatus(response, result.status === 'down' ? 503 : 200);
83
+ return result;
84
+ }
85
+ catch (error) {
86
+ return this.handleFailure(response, error);
87
+ }
88
+ }
89
+ handleFailure(response, error) {
90
+ setHttpStatus(response, 503);
91
+ return {
92
+ status: 'down',
93
+ error: 'Health check execution failed',
94
+ message: error?.message ?? 'Unknown error',
95
+ };
96
+ }
97
+ };
98
+ exports.HealthkitController = HealthkitController;
99
+ __decorate([
100
+ (0, common_1.Get)('live'),
101
+ __param(0, (0, common_1.Res)({ passthrough: true })),
102
+ __metadata("design:type", Function),
103
+ __metadata("design:paramtypes", [Object]),
104
+ __metadata("design:returntype", Promise)
105
+ ], HealthkitController.prototype, "live", null);
106
+ __decorate([
107
+ (0, common_1.Get)('ready'),
108
+ __param(0, (0, common_1.Res)({ passthrough: true })),
109
+ __metadata("design:type", Function),
110
+ __metadata("design:paramtypes", [Object]),
111
+ __metadata("design:returntype", Promise)
112
+ ], HealthkitController.prototype, "ready", null);
113
+ __decorate([
114
+ (0, common_1.Get)(),
115
+ __param(0, (0, common_1.Res)({ passthrough: true })),
116
+ __metadata("design:type", Function),
117
+ __metadata("design:paramtypes", [Object]),
118
+ __metadata("design:returntype", Promise)
119
+ ], HealthkitController.prototype, "root", null);
120
+ __decorate([
121
+ (0, common_1.Get)('ui'),
122
+ __param(0, (0, common_1.Res)({ passthrough: true })),
123
+ __metadata("design:type", Function),
124
+ __metadata("design:paramtypes", [Object]),
125
+ __metadata("design:returntype", Promise)
126
+ ], HealthkitController.prototype, "ui", null);
127
+ exports.HealthkitController = HealthkitController = __decorate([
128
+ (0, common_1.Controller)('health'),
129
+ (0, common_1.UseGuards)(HealthkitAuthGuard),
130
+ __param(0, (0, common_1.Inject)(exports.HEALTHKIT_CONTROLLER_PATH_READY)),
131
+ __param(2, (0, common_1.Inject)(healthkit_constants_1.HEALTHKIT_OPTIONS)),
132
+ __metadata("design:paramtypes", [Boolean, healthkit_service_1.HealthkitService, Object])
133
+ ], HealthkitController);
134
+ function setHttpStatus(response, statusCode) {
135
+ if (typeof response.status === 'function') {
136
+ response.status(statusCode);
137
+ return;
138
+ }
139
+ if (typeof response.code === 'function') {
140
+ response.code(statusCode);
141
+ return;
142
+ }
143
+ response.statusCode = statusCode;
144
+ }
145
+ function setHeader(response, name, value) {
146
+ if (typeof response.header === 'function') {
147
+ response.header(name, value);
148
+ return;
149
+ }
150
+ if (typeof response.setHeader === 'function') {
151
+ response.setHeader(name, value);
152
+ }
153
+ }
154
+ //# sourceMappingURL=healthkit.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthkit.controller.js","sourceRoot":"","sources":["../src/healthkit.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AAGxB,+DAA0D;AAE1D,2DAAuD;AACvD,wDAAsD;AAEzC,QAAA,+BAA+B,GAAG,MAAM,CACnD,iCAAiC,CAClC,CAAC;AAeK,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAEmB,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;IAC/C,CAAC;IAEJ,WAAW,CAAC,OAAyB;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAmB,CAAC;QACrE,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;QAEvC,KAAK,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YACtE,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;YAEzE,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;gBAC7B,MAAM,IAAI,8BAAqB,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,C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"}
@@ -0,0 +1,69 @@
1
+ import type { FactoryProvider, ModuleMetadata, Type } from '@nestjs/common';
2
+ export type HealthStatus = 'up' | 'down' | 'degraded';
3
+ export interface HealthIndicatorResult {
4
+ name: string;
5
+ status: HealthStatus;
6
+ message?: string;
7
+ details?: Record<string, unknown>;
8
+ durationMs: number;
9
+ }
10
+ export interface HealthCheckResult {
11
+ status: HealthStatus;
12
+ timestamp: string;
13
+ uptime: number;
14
+ checks: HealthIndicatorResult[];
15
+ }
16
+ export type HealthCheckFn = () => Promise<HealthIndicatorResult>;
17
+ export interface HealthkitModuleOptions {
18
+ path?: string;
19
+ ui?: boolean;
20
+ authHeaders?: Record<string, string>;
21
+ timeout?: number;
22
+ cacheTtl?: number;
23
+ indicators?: {
24
+ prisma?: PrismaIndicatorOptions;
25
+ typeorm?: TypeOrmIndicatorOptions;
26
+ redis?: RedisIndicatorOptions;
27
+ http?: HttpIndicatorOptions | HttpIndicatorOptions[];
28
+ memory?: MemoryIndicatorOptions;
29
+ disk?: DiskIndicatorOptions;
30
+ };
31
+ }
32
+ export interface PrismaIndicatorOptions {
33
+ prismaToken?: string | symbol | Type<unknown>;
34
+ name?: string;
35
+ }
36
+ export interface TypeOrmIndicatorOptions {
37
+ connectionName?: string;
38
+ name?: string;
39
+ }
40
+ export interface RedisIndicatorOptions {
41
+ redisToken?: string | symbol | Type<unknown>;
42
+ name?: string;
43
+ }
44
+ export interface HttpIndicatorOptions {
45
+ url: string;
46
+ name?: string;
47
+ timeout?: number;
48
+ expectedStatus?: number;
49
+ }
50
+ export interface MemoryIndicatorOptions {
51
+ heapThreshold?: number;
52
+ heapCritical?: number;
53
+ name?: string;
54
+ }
55
+ export interface DiskIndicatorOptions {
56
+ path?: string;
57
+ thresholdPercent?: number;
58
+ criticalPercent?: number;
59
+ name?: string;
60
+ }
61
+ export interface HealthkitOptionsFactory {
62
+ createHealthkitOptions(): Promise<HealthkitModuleOptions> | HealthkitModuleOptions;
63
+ }
64
+ export interface HealthkitModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
65
+ useExisting?: Type<HealthkitOptionsFactory>;
66
+ useClass?: Type<HealthkitOptionsFactory>;
67
+ useFactory?: (...args: any[]) => Promise<HealthkitModuleOptions> | HealthkitModuleOptions;
68
+ inject?: FactoryProvider['inject'];
69
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=healthkit.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthkit.interfaces.js","sourceRoot":"","sources":["../src/healthkit.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import type { HealthkitModuleAsyncOptions, HealthkitModuleOptions } from './healthkit.interfaces';
3
+ type SyncOptions = HealthkitModuleOptions;
4
+ declare const BaseHealthkitModule: import("@nestjs/common").ConfigurableModuleCls<HealthkitModuleOptions, "forRoot", "createHealthkitOptions", {}>;
5
+ export declare class HealthkitModule extends BaseHealthkitModule {
6
+ static forRoot(options?: SyncOptions): DynamicModule;
7
+ static forRootAsync(options: HealthkitModuleAsyncOptions): DynamicModule;
8
+ private static buildDynamicModule;
9
+ private static createProviders;
10
+ }
11
+ export {};