UNPKG

@innv/nest-initializer

Version:

Uma plataforma fluente e opinativa para inicializar e configurar aplicações NestJS com as melhores práticas.

49 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HealthController = exports.HEALTH_CHECK_OPTIONS = void 0; const tslib_1 = require("tslib"); const common_1 = require("@nestjs/common"); const terminus_1 = require("@nestjs/terminus"); const terminusHealthCheckModule = tslib_1.__importStar(require("./terminus-health-check.module")); exports.HEALTH_CHECK_OPTIONS = 'HEALTH_CHECK_OPTIONS'; let HealthController = class HealthController { options; health; db; memory; constructor(options, health, db, memory) { this.options = options; this.health = health; this.db = db; this.memory = memory; } check() { const checks = []; if (this.options.database && this.db) { checks.push(() => this.db.pingCheck('database')); } if (this.options.memory) { const { heapThreshold = 200, rssThreshold = 300 } = this.options.memory; checks.push(() => this.memory.checkHeap('memory_heap', heapThreshold * 1024 * 1024)); checks.push(() => this.memory.checkRSS('memory_rss', rssThreshold * 1024 * 1024)); } return this.health.check(checks); } }; exports.HealthController = HealthController; tslib_1.__decorate([ (0, common_1.Get)(), (0, terminus_1.HealthCheck)(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0) ], HealthController.prototype, "check", null); exports.HealthController = HealthController = tslib_1.__decorate([ (0, common_1.Controller)('health'), tslib_1.__param(0, (0, common_1.Inject)(exports.HEALTH_CHECK_OPTIONS)), tslib_1.__param(2, (0, common_1.Optional)()), tslib_1.__metadata("design:paramtypes", [Object, terminus_1.HealthCheckService, terminus_1.TypeOrmHealthIndicator, terminus_1.MemoryHealthIndicator]) ], HealthController); //# sourceMappingURL=health.controller.js.map