UNPKG

redis-smq

Version:

A high-performance, reliable, and scalable message queue for Node.js.

29 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._parseExchangeParams = _parseExchangeParams; exports._getExchangeParams = _getExchangeParams; const configuration_js_1 = require("../../config-manager/configuration.js"); const index_js_1 = require("../../errors/index.js"); const validator_js_1 = require("../../common/redis/redis-keys/validator.js"); function _parseExchangeParams(exchange, type) { const exchangeParams = _getExchangeParams(exchange); if (exchangeParams instanceof index_js_1.InvalidExchangeParametersError) return exchangeParams; return Object.assign(Object.assign({}, exchangeParams), { type }); } function _getExchangeParams(exchange) { const exchangeParams = typeof exchange === 'string' ? { name: exchange, ns: configuration_js_1.Configuration.getConfig().namespace } : exchange; const ns = (0, validator_js_1.validateRedisKey)(exchangeParams.ns); if (ns instanceof Error) return new index_js_1.InvalidExchangeParametersError(); const name = (0, validator_js_1.validateRedisKey)(exchangeParams.name); if (name instanceof index_js_1.InvalidRedisKeyError) return new index_js_1.InvalidExchangeParametersError(); return { ns, name, }; } //# sourceMappingURL=_parse-exchange-params.js.map