UNPKG

@duongtrungnguyen/nestro

Version:
42 lines 1.84 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 communicate_request_decorator_exports = {}; __export(communicate_request_decorator_exports, { CommunicateRequest: () => CommunicateRequest }); module.exports = __toCommonJS(communicate_request_decorator_exports); var import_discovery = require("../../discovery"); function CommunicateRequest(serviceName) { return function(_, __, descriptor) { const originalMethod = descriptor.value; descriptor.value = async function(...args) { if (!this._discoveryService && !(this._discoveryService instanceof import_discovery.DiscoveryService)) { throw new Error("Missing _discoveryService on class. Ensure it extends CommunicationTemplate."); } return this?._discoveryService.discover(serviceName || this.targetService, async (instance) => { return await originalMethod.apply(this, [instance, ...args]); }); }; return descriptor; }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CommunicateRequest }); //# sourceMappingURL=communicate-request.decorator.js.map