UNPKG

nats-micro

Version:

NATS micro compatible extra-lightweight microservice library

28 lines 1.58 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.wrapMethod = void 0; const callHandler_js_1 = require("./callHandler.js"); const debug_js_1 = require("../debug.js"); function wrapMethod(broker, callback, handlerInfo) { return (msg, subject) => __awaiter(this, void 0, void 0, function* () { var _a; debug_js_1.debug.ms.thread.debug(`Executing ${handlerInfo.method}(${JSON.stringify(msg.data)})`); const output = yield (0, callHandler_js_1.callHandler)(callback, msg.data, subject, (_a = msg.headers) !== null && _a !== void 0 ? _a : [], handlerInfo); if ((typeof (output.data) !== 'symbol') && 'replyTo' in msg && msg.replyTo) { broker.send(msg.replyTo, output.data, { headers: output.headers, }); } }); } exports.wrapMethod = wrapMethod; //# sourceMappingURL=wrapMethod.js.map