@lenne.tech/nest-server 11.46.10 → 11.46.11
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/FRAMEWORK-API.md +1 -1
- package/dist/core/modules/health-check/core-health-check.service.d.ts +12 -0
- package/dist/core/modules/health-check/core-health-check.service.js +40 -2
- package/dist/core/modules/health-check/core-health-check.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/migration-guides/11.46.10-to-11.46.11.md +57 -0
- package/package.json +1 -1
- package/src/core/modules/health-check/core-health-check.service.ts +74 -3
package/FRAMEWORK-API.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lenne.tech/nest-server — Framework API Reference
|
|
2
2
|
|
|
3
|
-
> Auto-generated from source code as of 2026-12-04 (v11.46.
|
|
3
|
+
> Auto-generated from source code as of 2026-12-04 (v11.46.11)
|
|
4
4
|
> File: `FRAMEWORK-API.md` — compact, machine-readable API surface for Claude Code
|
|
5
5
|
|
|
6
6
|
## CoreModule.forRoot()
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { DiskHealthIndicator, HealthCheckResult, HealthCheckService, MemoryHealthIndicator, MongooseHealthIndicator } from '@nestjs/terminus';
|
|
2
|
+
import type { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health.js';
|
|
2
3
|
import { ConfigService } from '../../common/services/config.service';
|
|
4
|
+
export declare const DEFAULT_DATABASE_PING_TIMEOUT_MS = 2000;
|
|
5
|
+
export interface IHealthCheckMongoConnection {
|
|
6
|
+
db?: {
|
|
7
|
+
command(command: Record<string, unknown>): Promise<unknown>;
|
|
8
|
+
} | null;
|
|
9
|
+
}
|
|
3
10
|
export declare class CoreHealthCheckService {
|
|
4
11
|
protected config: ConfigService;
|
|
5
12
|
protected db: MongooseHealthIndicator;
|
|
@@ -7,5 +14,10 @@ export declare class CoreHealthCheckService {
|
|
|
7
14
|
protected health: HealthCheckService;
|
|
8
15
|
protected memory: MemoryHealthIndicator;
|
|
9
16
|
constructor(config: ConfigService, db: MongooseHealthIndicator, disk: DiskHealthIndicator, health: HealthCheckService, memory: MemoryHealthIndicator);
|
|
17
|
+
protected mongoConnection?: IHealthCheckMongoConnection | null;
|
|
10
18
|
healthCheck(): Promise<HealthCheckResult>;
|
|
19
|
+
protected mongoPingCheck(key: string, options: MongoosePingCheckSettings): Promise<import("@nestjs/terminus").HealthIndicatorResult<string> | import("@nestjs/terminus").HealthIndicatorResult<string, "down", {
|
|
20
|
+
message: string;
|
|
21
|
+
}>>;
|
|
22
|
+
protected pingMongoDb(connection: IHealthCheckMongoConnection): Promise<void>;
|
|
11
23
|
}
|
|
@@ -9,11 +9,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CoreHealthCheckService = void 0;
|
|
12
|
+
exports.CoreHealthCheckService = exports.DEFAULT_DATABASE_PING_TIMEOUT_MS = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
15
|
const terminus_1 = require("@nestjs/terminus");
|
|
15
16
|
const meta_helper_1 = require("../../common/helpers/meta.helper");
|
|
16
17
|
const config_service_1 = require("../../common/services/config.service");
|
|
18
|
+
exports.DEFAULT_DATABASE_PING_TIMEOUT_MS = 2000;
|
|
17
19
|
let CoreHealthCheckService = class CoreHealthCheckService {
|
|
18
20
|
config;
|
|
19
21
|
db;
|
|
@@ -27,10 +29,11 @@ let CoreHealthCheckService = class CoreHealthCheckService {
|
|
|
27
29
|
this.health = health;
|
|
28
30
|
this.memory = memory;
|
|
29
31
|
}
|
|
32
|
+
mongoConnection;
|
|
30
33
|
healthCheck() {
|
|
31
34
|
const healthIndicatorFunctions = [];
|
|
32
35
|
if (this.config.get('healthCheck.configs.database.enabled')) {
|
|
33
|
-
healthIndicatorFunctions.push(() => this.
|
|
36
|
+
healthIndicatorFunctions.push(() => this.mongoPingCheck(this.config.get('healthCheck.configs.database.key') ?? 'database', this.config.get('healthCheck.configs.database.options') ?? {}));
|
|
34
37
|
}
|
|
35
38
|
if (this.config.get('healthCheck.configs.memoryHeap.enabled')) {
|
|
36
39
|
healthIndicatorFunctions.push(() => this.memory.checkHeap(this.config.get('healthCheck.configs.memoryHeap.key') ?? 'memoryHeap', this.config.get('healthCheck.configs.memoryHeap.heapUsedThreshold') ?? 4 * 1024 * 1024 * 1024));
|
|
@@ -50,8 +53,43 @@ let CoreHealthCheckService = class CoreHealthCheckService {
|
|
|
50
53
|
}
|
|
51
54
|
return this.health.check(healthIndicatorFunctions);
|
|
52
55
|
}
|
|
56
|
+
async mongoPingCheck(key, options) {
|
|
57
|
+
const connection = options.connection ?? this.mongoConnection;
|
|
58
|
+
if (!connection) {
|
|
59
|
+
return this.db.pingCheck(key, { timeout: exports.DEFAULT_DATABASE_PING_TIMEOUT_MS, ...options });
|
|
60
|
+
}
|
|
61
|
+
const timeout = options.timeout || exports.DEFAULT_DATABASE_PING_TIMEOUT_MS;
|
|
62
|
+
const check = new terminus_1.HealthIndicatorService().check(key);
|
|
63
|
+
let timer;
|
|
64
|
+
try {
|
|
65
|
+
await Promise.race([
|
|
66
|
+
this.pingMongoDb(connection),
|
|
67
|
+
new Promise((_, reject) => {
|
|
68
|
+
timer = setTimeout(() => reject(new Error(`timeout of ${timeout}ms exceeded`)), timeout);
|
|
69
|
+
}),
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return check.down({ message: error?.message ?? String(error) });
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
clearTimeout(timer);
|
|
77
|
+
}
|
|
78
|
+
return check.up();
|
|
79
|
+
}
|
|
80
|
+
async pingMongoDb(connection) {
|
|
81
|
+
if (!connection.db) {
|
|
82
|
+
throw new Error('Not connected to database');
|
|
83
|
+
}
|
|
84
|
+
await connection.db.command({ ping: 1 });
|
|
85
|
+
}
|
|
53
86
|
};
|
|
54
87
|
exports.CoreHealthCheckService = CoreHealthCheckService;
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, common_1.Optional)(),
|
|
90
|
+
(0, mongoose_1.InjectConnection)(),
|
|
91
|
+
__metadata("design:type", Object)
|
|
92
|
+
], CoreHealthCheckService.prototype, "mongoConnection", void 0);
|
|
55
93
|
exports.CoreHealthCheckService = CoreHealthCheckService = __decorate([
|
|
56
94
|
(0, common_1.Injectable)(),
|
|
57
95
|
__metadata("design:paramtypes", [config_service_1.ConfigService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-health-check.service.js","sourceRoot":"","sources":["../../../../src/core/modules/health-check/core-health-check.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"core-health-check.service.js","sourceRoot":"","sources":["../../../../src/core/modules/health-check/core-health-check.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAsD;AACtD,+CAAoD;AACpD,+CAO0B;AAI1B,kEAAgE;AAChE,yEAAqE;AASxD,QAAA,gCAAgC,GAAG,IAAI,CAAC;AAY9C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAErB;IACA;IACA;IACA;IACA;IALZ,YACY,MAAqB,EACrB,EAA2B,EAC3B,IAAyB,EACzB,MAA0B,EAC1B,MAA6B;QAJ7B,WAAM,GAAN,MAAM,CAAe;QACrB,OAAE,GAAF,EAAE,CAAyB;QAC3B,SAAI,GAAJ,IAAI,CAAqB;QACzB,WAAM,GAAN,MAAM,CAAoB;QAC1B,WAAM,GAAN,MAAM,CAAuB;IACtC,CAAC;IAQM,eAAe,CAAsC;IAE/D,WAAW;QACT,MAAM,wBAAwB,GAAG,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAU,s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