UNPKG

@duongtrungnguyen/nestro

Version:
69 lines 2.79 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index); var registry_service_exports = {}; __export(registry_service_exports, { RegistryService: () => RegistryService }); module.exports = __toCommonJS(registry_service_exports); var import_common = require("@nestjs/common"); var import_storage = require("../../storage"); var import_common2 = require("../../common"); let RegistryService = class { constructor(storageOptions, storage) { this.storageOptions = storageOptions; this.storage = storage; } beforeApplicationShutdown() { (0, import_common2.debugLog)("Nestro server", "Nestro server stopping"); } async register(service) { const key = service.name; await this.storage.register(key, service); return { heartbeatInterval: this.storageOptions.heartbeatInterval }; } async deregister(service) { await this.storage.deregister(service.name, service); return { message: "Deregistered" }; } async heartbeat(service) { await this.storage.heartbeat(service.name, service); return { message: "Heartbeat received" }; } async getServices(serviceName) { return await this.storage.getServices(serviceName); } }; RegistryService = __decorateClass([ (0, import_common.Injectable)(), __decorateParam(0, (0, import_common.Inject)(import_storage.STORAGE_OPTIONS)), __decorateParam(1, (0, import_common.Inject)(import_storage.STORAGE)) ], RegistryService); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { RegistryService }); //# sourceMappingURL=registry.service.js.map