redis-smq
Version:
A high-performance, reliable, and scalable message queue for Node.js.
28 lines • 1.1 kB
JavaScript
import { Configuration } from '../../config-manager/configuration.js';
import { InvalidExchangeParametersError, InvalidRedisKeyError, } from '../../errors/index.js';
import { validateRedisKey } from '../../common/redis/redis-keys/validator.js';
export function _parseExchangeParams(exchange, type) {
const exchangeParams = _getExchangeParams(exchange);
if (exchangeParams instanceof InvalidExchangeParametersError)
return exchangeParams;
return {
...exchangeParams,
type,
};
}
export function _getExchangeParams(exchange) {
const exchangeParams = typeof exchange === 'string'
? { name: exchange, ns: Configuration.getConfig().namespace }
: exchange;
const ns = validateRedisKey(exchangeParams.ns);
if (ns instanceof Error)
return new InvalidExchangeParametersError();
const name = validateRedisKey(exchangeParams.name);
if (name instanceof InvalidRedisKeyError)
return new InvalidExchangeParametersError();
return {
ns,
name,
};
}
//# sourceMappingURL=_parse-exchange-params.js.map