@rxap/nest-rabbitmq
Version:
This package provides a NestJS module for integrating with RabbitMQ using exchanges. It offers a client and server implementation for message queuing and supports features like health checks and error serialization. It simplifies the process of setting up
34 lines (33 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RabbitMqIncomingRequestDeserializer = void 0;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
class RabbitMqIncomingRequestDeserializer {
deserialize(value, options) {
return this.isExternal(value) ? this.mapToSchema(value, options) : value;
}
isExternal(value) {
if (!value) {
return true;
}
if (!(0, shared_utils_1.isUndefined)(value.pattern) ||
!(0, shared_utils_1.isUndefined)(value.data)) {
return false;
}
return true;
}
mapToSchema(value, options) {
if (!options) {
return {
pattern: undefined,
data: undefined,
};
}
return {
id: options.properties['correlationId'],
pattern: options.fields['routingKey'],
data: value,
};
}
}
exports.RabbitMqIncomingRequestDeserializer = RabbitMqIncomingRequestDeserializer;