@laboratory-one/api-components 0.0.4 → 0.0.5
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/dist/cjs/health/dtos/health.response.dto.d.ts +6 -7
- package/dist/cjs/health/dtos/health.response.dto.d.ts.map +1 -1
- package/dist/cjs/health/dtos/health.response.dto.js +0 -2
- package/dist/cjs/health/dtos/health.response.dto.js.map +1 -1
- package/dist/cjs/health/health.service.d.ts +2 -3
- package/dist/cjs/health/health.service.d.ts.map +1 -1
- package/dist/cjs/health/health.service.js +1 -4
- package/dist/cjs/health/health.service.js.map +1 -1
- package/dist/esm/health/dtos/health.response.dto.d.ts +6 -7
- package/dist/esm/health/dtos/health.response.dto.d.ts.map +1 -1
- package/dist/esm/health/dtos/health.response.dto.js +0 -2
- package/dist/esm/health/dtos/health.response.dto.js.map +1 -1
- package/dist/esm/health/health.service.d.ts +2 -3
- package/dist/esm/health/health.service.d.ts.map +1 -1
- package/dist/esm/health/health.service.js +2 -5
- package/dist/esm/health/health.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/health/dtos/health.response.dto.ts +10 -9
- package/src/health/health.service.ts +1 -4
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
details: healthIndicator.HealthIndicatorResult;
|
|
1
|
+
import type { HealthCheckResult, HealthCheckStatus, HealthIndicatorResult } from '@nestjs/terminus';
|
|
2
|
+
export declare class HealthResponseDto implements HealthCheckResult {
|
|
3
|
+
status: HealthCheckStatus;
|
|
4
|
+
info?: HealthIndicatorResult;
|
|
5
|
+
error?: HealthIndicatorResult;
|
|
6
|
+
details: HealthIndicatorResult;
|
|
8
7
|
environment: string;
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=health.response.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.response.dto.d.ts","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"health.response.dto.d.ts","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAkB,YAAW,iBAAiB;IAEzD,MAAM,EAAE,iBAAiB,CAAC;IAG1B,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAG7B,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAG9B,OAAO,EAAE,qBAAqB,CAAC;IAI/B,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HealthResponseDto = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const healthCheckResultInterface = tslib_1.__importStar(require("@nestjs/terminus/dist/health-check/health-check-result.interface"));
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
8
|
-
const healthIndicator = tslib_1.__importStar(require("@nestjs/terminus/dist/health-indicator"));
|
|
9
7
|
class HealthResponseDto {
|
|
10
8
|
}
|
|
11
9
|
exports.HealthResponseDto = HealthResponseDto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.response.dto.js","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"health.response.dto.js","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":";;;;AAAA,qDAA2C;AAC3C,6CAA8C;AAO9C,MAAa,iBAAiB;CAgB7B;AAhBD,8CAgBC;AAdC;IADC,IAAA,qBAAW,GAAE;;iDACY;AAG1B;IADC,IAAA,qBAAW,GAAE;;+CACe;AAG7B;IADC,IAAA,qBAAW,GAAE;;gDACgB;AAG9B;IADC,IAAA,qBAAW,GAAE;;kDACiB;AAI/B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAW,GAAE;;sDACM","sourcesContent":["import { IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\nimport type {\n HealthCheckResult,\n HealthCheckStatus,\n HealthIndicatorResult,\n} from '@nestjs/terminus';\n\nexport class HealthResponseDto implements HealthCheckResult {\n @ApiProperty()\n status: HealthCheckStatus;\n\n @ApiProperty()\n info?: HealthIndicatorResult;\n\n @ApiProperty()\n error?: HealthIndicatorResult;\n\n @ApiProperty()\n details: HealthIndicatorResult;\n\n @IsString()\n @ApiProperty()\n environment: string;\n}\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { HealthCheckService,
|
|
1
|
+
import { HealthCheckService, MemoryHealthIndicator } from '@nestjs/terminus';
|
|
2
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
3
|
import { HealthResponseDto } from './dtos/health.response.dto';
|
|
4
4
|
export declare class HealthService {
|
|
5
5
|
private readonly configService;
|
|
6
6
|
private readonly health;
|
|
7
|
-
private readonly http;
|
|
8
7
|
private readonly memory;
|
|
9
8
|
private readonly logger;
|
|
10
|
-
constructor(configService: ConfigService, health: HealthCheckService,
|
|
9
|
+
constructor(configService: ConfigService, health: HealthCheckService, memory: MemoryHealthIndicator);
|
|
11
10
|
check(): Promise<HealthResponseDto>;
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=health.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.service.d.ts","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"health.service.d.ts","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAI/D,qBACa,aAAa;IAKtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;gBAG9C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,qBAAqB;IAG1C,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAgB1C"}
|
|
@@ -7,17 +7,15 @@ const common_1 = require("@nestjs/common");
|
|
|
7
7
|
const terminus_1 = require("@nestjs/terminus");
|
|
8
8
|
const config_1 = require("@nestjs/config");
|
|
9
9
|
let HealthService = HealthService_1 = class HealthService {
|
|
10
|
-
constructor(configService, health,
|
|
10
|
+
constructor(configService, health, memory) {
|
|
11
11
|
this.configService = configService;
|
|
12
12
|
this.health = health;
|
|
13
|
-
this.http = http;
|
|
14
13
|
this.memory = memory;
|
|
15
14
|
this.logger = new common_1.Logger(HealthService_1.name);
|
|
16
15
|
}
|
|
17
16
|
async check() {
|
|
18
17
|
this.logger.log('check');
|
|
19
18
|
const statuses = await this.health.check([
|
|
20
|
-
async () => this.http.pingCheck('website', 'https://google.com'),
|
|
21
19
|
async () => this.memory.checkHeap('memoryHeap', 200 * 1024 * 1024),
|
|
22
20
|
async () => this.memory.checkRSS('memoryRss', 3000 * 1024 * 1024),
|
|
23
21
|
]);
|
|
@@ -30,7 +28,6 @@ exports.HealthService = HealthService = HealthService_1 = tslib_1.__decorate([
|
|
|
30
28
|
(0, common_1.Injectable)(),
|
|
31
29
|
tslib_1.__metadata("design:paramtypes", [config_1.ConfigService,
|
|
32
30
|
terminus_1.HealthCheckService,
|
|
33
|
-
terminus_1.HttpHealthIndicator,
|
|
34
31
|
terminus_1.MemoryHealthIndicator])
|
|
35
32
|
], HealthService);
|
|
36
33
|
//# sourceMappingURL=health.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.service.js","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,+CAI0B;AAC1B,2CAA+C;
|
|
1
|
+
{"version":3,"file":"health.service.js","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,+CAI0B;AAC1B,2CAA+C;AAOxC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAIxB,YACmB,aAA4B,EAC5B,MAA0B,EAC1B,MAA6B;QAF7B,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAoB;QAC1B,WAAM,GAAN,MAAM,CAAuB;QAL/B,WAAM,GAAW,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAM9D,CAAC;IAEJ,KAAK,CAAC,KAAK;QAET,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEzB,MAAM,QAAQ,GAAsB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAC1D,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;YAClE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;SAClE,CAAC,CAAC;QAEH,MAAM,WAAW,GAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC;QAEvE,uBACE,WAAW,IACR,QAAQ,EACX;IACJ,CAAC;CACF,CAAA;AA1BY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;6CAMuB,sBAAa;QACpB,6BAAkB;QAClB,gCAAqB;GAPrC,aAAa,CA0BzB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport {\n HealthCheckResult,\n HealthCheckService,\n MemoryHealthIndicator,\n} from '@nestjs/terminus';\nimport { ConfigService } from '@nestjs/config';\n\nimport { HealthResponseDto } from './dtos/health.response.dto';\n\n// this decorator indicates to nest that this class can be provided to a module\n// we want to handle logic in services to keep our resolvers and controllers clean\n@Injectable()\nexport class HealthService {\n // grab the global logger instance\n private readonly logger: Logger = new Logger(HealthService.name);\n\n constructor(\n private readonly configService: ConfigService,\n private readonly health: HealthCheckService,\n private readonly memory: MemoryHealthIndicator,\n ) {}\n\n async check(): Promise<HealthResponseDto> {\n // this logger has several logging levels\n this.logger.log('check');\n\n const statuses: HealthCheckResult = await this.health.check([\n async () => this.memory.checkHeap('memoryHeap', 200 * 1024 * 1024),\n async () => this.memory.checkRSS('memoryRss', 3000 * 1024 * 1024),\n ]);\n\n const environment: string = this.configService.get<string>('NODE_ENV');\n\n return {\n environment,\n ...statuses,\n };\n }\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
details: healthIndicator.HealthIndicatorResult;
|
|
1
|
+
import type { HealthCheckResult, HealthCheckStatus, HealthIndicatorResult } from '@nestjs/terminus';
|
|
2
|
+
export declare class HealthResponseDto implements HealthCheckResult {
|
|
3
|
+
status: HealthCheckStatus;
|
|
4
|
+
info?: HealthIndicatorResult;
|
|
5
|
+
error?: HealthIndicatorResult;
|
|
6
|
+
details: HealthIndicatorResult;
|
|
8
7
|
environment: string;
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=health.response.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.response.dto.d.ts","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"health.response.dto.d.ts","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAkB,YAAW,iBAAiB;IAEzD,MAAM,EAAE,iBAAiB,CAAC;IAG1B,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAG7B,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAG9B,OAAO,EAAE,qBAAqB,CAAC;IAI/B,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import * as healthCheckResultInterface from '@nestjs/terminus/dist/health-check/health-check-result.interface';
|
|
3
2
|
import { IsString } from 'class-validator';
|
|
4
3
|
import { ApiProperty } from '@nestjs/swagger';
|
|
5
|
-
import * as healthIndicator from '@nestjs/terminus/dist/health-indicator';
|
|
6
4
|
export class HealthResponseDto {
|
|
7
5
|
}
|
|
8
6
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.response.dto.js","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"health.response.dto.js","sourceRoot":"/","sources":["health/dtos/health.response.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAO9C,MAAM,OAAO,iBAAiB;CAgB7B;AAdC;IADC,WAAW,EAAE;;iDACY;AAG1B;IADC,WAAW,EAAE;;+CACe;AAG7B;IADC,WAAW,EAAE;;gDACgB;AAG9B;IADC,WAAW,EAAE;;kDACiB;AAI/B;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;sDACM","sourcesContent":["import { IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\nimport type {\n HealthCheckResult,\n HealthCheckStatus,\n HealthIndicatorResult,\n} from '@nestjs/terminus';\n\nexport class HealthResponseDto implements HealthCheckResult {\n @ApiProperty()\n status: HealthCheckStatus;\n\n @ApiProperty()\n info?: HealthIndicatorResult;\n\n @ApiProperty()\n error?: HealthIndicatorResult;\n\n @ApiProperty()\n details: HealthIndicatorResult;\n\n @IsString()\n @ApiProperty()\n environment: string;\n}\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { HealthCheckService,
|
|
1
|
+
import { HealthCheckService, MemoryHealthIndicator } from '@nestjs/terminus';
|
|
2
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
3
|
import { HealthResponseDto } from './dtos/health.response.dto';
|
|
4
4
|
export declare class HealthService {
|
|
5
5
|
private readonly configService;
|
|
6
6
|
private readonly health;
|
|
7
|
-
private readonly http;
|
|
8
7
|
private readonly memory;
|
|
9
8
|
private readonly logger;
|
|
10
|
-
constructor(configService: ConfigService, health: HealthCheckService,
|
|
9
|
+
constructor(configService: ConfigService, health: HealthCheckService, memory: MemoryHealthIndicator);
|
|
11
10
|
check(): Promise<HealthResponseDto>;
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=health.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.service.d.ts","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"health.service.d.ts","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAI/D,qBACa,aAAa;IAKtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;gBAG9C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,qBAAqB;IAG1C,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAgB1C"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
var HealthService_1;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
3
|
import { Injectable, Logger } from '@nestjs/common';
|
|
4
|
-
import { HealthCheckService,
|
|
4
|
+
import { HealthCheckService, MemoryHealthIndicator, } from '@nestjs/terminus';
|
|
5
5
|
import { ConfigService } from '@nestjs/config';
|
|
6
6
|
let HealthService = HealthService_1 = class HealthService {
|
|
7
|
-
constructor(configService, health,
|
|
7
|
+
constructor(configService, health, memory) {
|
|
8
8
|
this.configService = configService;
|
|
9
9
|
this.health = health;
|
|
10
|
-
this.http = http;
|
|
11
10
|
this.memory = memory;
|
|
12
11
|
this.logger = new Logger(HealthService_1.name);
|
|
13
12
|
}
|
|
14
13
|
async check() {
|
|
15
14
|
this.logger.log('check');
|
|
16
15
|
const statuses = await this.health.check([
|
|
17
|
-
async () => this.http.pingCheck('website', 'https://google.com'),
|
|
18
16
|
async () => this.memory.checkHeap('memoryHeap', 200 * 1024 * 1024),
|
|
19
17
|
async () => this.memory.checkRSS('memoryRss', 3000 * 1024 * 1024),
|
|
20
18
|
]);
|
|
@@ -26,7 +24,6 @@ HealthService = HealthService_1 = __decorate([
|
|
|
26
24
|
Injectable(),
|
|
27
25
|
__metadata("design:paramtypes", [ConfigService,
|
|
28
26
|
HealthCheckService,
|
|
29
|
-
HttpHealthIndicator,
|
|
30
27
|
MemoryHealthIndicator])
|
|
31
28
|
], HealthService);
|
|
32
29
|
export { HealthService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.service.js","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"health.service.js","sourceRoot":"/","sources":["health/health.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAEL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAOxC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAIxB,YACmB,aAA4B,EAC5B,MAA0B,EAC1B,MAA6B;QAF7B,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAoB;QAC1B,WAAM,GAAN,MAAM,CAAuB;QAL/B,WAAM,GAAW,IAAI,MAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAM9D,CAAC;IAEJ,KAAK,CAAC,KAAK;QAET,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEzB,MAAM,QAAQ,GAAsB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAC1D,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;YAClE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;SAClE,CAAC,CAAC;QAEH,MAAM,WAAW,GAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC;QAEvE,uBACE,WAAW,IACR,QAAQ,EACX;IACJ,CAAC;CACF,CAAA;AA1BY,aAAa;IADzB,UAAU,EAAE;qCAMuB,aAAa;QACpB,kBAAkB;QAClB,qBAAqB;GAPrC,aAAa,CA0BzB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport {\n HealthCheckResult,\n HealthCheckService,\n MemoryHealthIndicator,\n} from '@nestjs/terminus';\nimport { ConfigService } from '@nestjs/config';\n\nimport { HealthResponseDto } from './dtos/health.response.dto';\n\n// this decorator indicates to nest that this class can be provided to a module\n// we want to handle logic in services to keep our resolvers and controllers clean\n@Injectable()\nexport class HealthService {\n // grab the global logger instance\n private readonly logger: Logger = new Logger(HealthService.name);\n\n constructor(\n private readonly configService: ConfigService,\n private readonly health: HealthCheckService,\n private readonly memory: MemoryHealthIndicator,\n ) {}\n\n async check(): Promise<HealthResponseDto> {\n // this logger has several logging levels\n this.logger.log('check');\n\n const statuses: HealthCheckResult = await this.health.check([\n async () => this.memory.checkHeap('memoryHeap', 200 * 1024 * 1024),\n async () => this.memory.checkRSS('memoryRss', 3000 * 1024 * 1024),\n ]);\n\n const environment: string = this.configService.get<string>('NODE_ENV');\n\n return {\n environment,\n ...statuses,\n };\n }\n}\n"]}
|