@orion-js/echoes
Advanced tools
Comparing version 2.1.0 to 2.2.1
@@ -8,7 +8,9 @@ "use strict"; | ||
}); | ||
exports.default = _default; | ||
exports.default = void 0; | ||
var _deserialize = _interopRequireDefault(require("./deserialize")); | ||
function _default(options) { | ||
var _types = _interopRequireDefault(require("./types")); | ||
const echo = function (options) { | ||
return { ...options, | ||
@@ -27,4 +29,14 @@ onMessage: async messageData => { | ||
await options.resolve(data.params, context); | ||
}, | ||
onRequest: async serializedParams => { | ||
const context = {}; | ||
const params = (0, _deserialize.default)(serializedParams); | ||
const result = await options.resolve(params, context); | ||
return result; | ||
} | ||
}; | ||
} | ||
}; | ||
echo.types = _types.default; | ||
var _default = echo; | ||
exports.default = _default; |
@@ -26,2 +26,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "request", { | ||
enumerable: true, | ||
get: function () { | ||
return _request.default; | ||
} | ||
}); | ||
@@ -32,2 +38,4 @@ var _startService = _interopRequireDefault(require("./startService")); | ||
var _echo = _interopRequireDefault(require("./echo")); | ||
var _echo = _interopRequireDefault(require("./echo")); | ||
var _request = _interopRequireDefault(require("./request")); |
@@ -14,2 +14,6 @@ "use strict"; | ||
var _requestsHandler = _interopRequireDefault(require("../requestsHandler")); | ||
var _types = _interopRequireDefault(require("../echo/types")); | ||
async function _default(options) { | ||
@@ -23,3 +27,3 @@ const kafka = new _kafkajs.Kafka(options.client); | ||
for (const topic in options.echoes) { | ||
await _config.default.consumer.subscribe({ | ||
_config.default.consumer.subscribe({ | ||
topic | ||
@@ -29,9 +33,19 @@ }); | ||
await _config.default.consumer.run({ | ||
_config.default.consumer.run({ | ||
eachMessage: async params => { | ||
const echo = options.echoes[params.topic]; | ||
if (!echo) return; | ||
if (echo.type !== _types.default.event) return; | ||
await echo.onMessage(params); | ||
} | ||
}); | ||
if (options.requests) { | ||
_config.default.requests = options.requests; | ||
_config.default.echoes = options.echoes; | ||
if (_config.default.requests.startHandler) { | ||
_config.default.requests.startHandler(_requestsHandler.default); | ||
} | ||
} | ||
} |
{ | ||
"name": "@orion-js/echoes", | ||
"version": "2.1.0", | ||
"version": "2.2.1", | ||
"main": "lib/index.js", | ||
@@ -16,2 +16,4 @@ "author": "nicolaslopezj", | ||
"@orion-js/helpers": "^2.1.0", | ||
"axios": "^0.23.0", | ||
"jssha": "^3.2.0", | ||
"kafkajs": "^1.15.0", | ||
@@ -30,3 +32,3 @@ "serialize-javascript": "^5.0.1" | ||
}, | ||
"gitHead": "000b9799ae0f89d0aa64b444510a305c1393352e" | ||
"gitHead": "60107059b7c8ebe1ef8cab2992ac528263d425b5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122931
18
308
5
+ Addedaxios@^0.23.0
+ Addedjssha@^3.2.0
+ Addedaxios@0.23.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedjssha@3.3.1(transitive)