resolve-bus-rabbitmq
Advanced tools
Comparing version 0.4.1-124084142.beta to 0.4.1-124150146.beta
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -16,80 +16,80 @@ | ||
var defaultOptions = { | ||
exchange: 'exchange', | ||
queueName: '', | ||
channelName: '', | ||
exchangeType: 'fanout', | ||
messageTtl: 2000, | ||
maxLength: 10000 | ||
exchange: 'exchange', | ||
queueName: '', | ||
channelName: '', | ||
exchangeType: 'fanout', | ||
messageTtl: 2000, | ||
maxLength: 10000 | ||
}; | ||
function init(_ref, handler) { | ||
var url = _ref.url, | ||
exchange = _ref.exchange, | ||
exchangeType = _ref.exchangeType, | ||
queueName = _ref.queueName, | ||
messageTtl = _ref.messageTtl, | ||
maxLength = _ref.maxLength; | ||
var url = _ref.url, | ||
exchange = _ref.exchange, | ||
exchangeType = _ref.exchangeType, | ||
queueName = _ref.queueName, | ||
messageTtl = _ref.messageTtl, | ||
maxLength = _ref.maxLength; | ||
return _amqplib2.default.connect(url).then(function (connection) { | ||
return connection.createChannel(); | ||
}).then(function (channel) { | ||
return channel.assertExchange(exchange, exchangeType, { | ||
durable: false | ||
}).then(function () { | ||
return channel; | ||
}); | ||
}).then(function (channel) { | ||
return channel | ||
// Additional options described here: | ||
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertQueue | ||
.assertQueue(queueName, { | ||
arguments: { | ||
messageTtl: messageTtl, | ||
maxLength: maxLength | ||
} | ||
}).then(function (queue) { | ||
return channel.bindQueue(queue.queue, exchange); | ||
}).then(function () { | ||
return channel.consume(queueName, function (msg) { | ||
if (msg) { | ||
var content = msg.content.toString(); | ||
var message = JSON.parse(content); | ||
handler(message); | ||
} | ||
}, { noAck: true }); | ||
}).then(function () { | ||
return channel; | ||
}); | ||
return _amqplib2.default.connect(url).then(function (connection) { | ||
return connection.createChannel(); | ||
}).then(function (channel) { | ||
return channel.assertExchange(exchange, exchangeType, { | ||
durable: false | ||
}).then(function () { | ||
return channel; | ||
}); | ||
}).then(function (channel) { | ||
return channel | ||
// Additional options described here: | ||
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertQueue | ||
.assertQueue(queueName, { | ||
arguments: { | ||
messageTtl: messageTtl, | ||
maxLength: maxLength | ||
} | ||
}).then(function (queue) { | ||
return channel.bindQueue(queue.queue, exchange); | ||
}).then(function () { | ||
return channel.consume(queueName, function (msg) { | ||
if (msg) { | ||
var content = msg.content.toString(); | ||
var message = JSON.parse(content); | ||
handler(message); | ||
} | ||
}, { noAck: true }); | ||
}).then(function () { | ||
return channel; | ||
}); | ||
}); | ||
} | ||
function createAdapter(options) { | ||
var handler = function handler() {}; | ||
var config = _extends({}, defaultOptions, options); | ||
var initPromise = init(config, function (event) { | ||
return handler(event); | ||
}); | ||
var exchange = config.exchange, | ||
queueName = config.queueName, | ||
messageTtl = config.messageTtl; | ||
var handler = function handler() {}; | ||
var config = _extends({}, defaultOptions, options); | ||
var initPromise = init(config, function (event) { | ||
return handler(event); | ||
}); | ||
var exchange = config.exchange, | ||
queueName = config.queueName, | ||
messageTtl = config.messageTtl; | ||
return { | ||
publish: function publish(event) { | ||
return initPromise.then(function (channel) { | ||
channel.publish(exchange, queueName, new Buffer(JSON.stringify(event)), | ||
// Additional options described here: | ||
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish | ||
{ | ||
expiration: messageTtl, | ||
persistent: false | ||
}); | ||
}); | ||
}, | ||
subscribe: function subscribe(callback) { | ||
return initPromise.then(function () { | ||
return handler = callback; | ||
}); | ||
} | ||
}; | ||
return { | ||
publish: function publish(event) { | ||
return initPromise.then(function (channel) { | ||
channel.publish(exchange, queueName, new Buffer(JSON.stringify(event)), | ||
// Additional options described here: | ||
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish | ||
{ | ||
expiration: messageTtl, | ||
persistent: false | ||
}); | ||
}); | ||
}, | ||
subscribe: function subscribe(callback) { | ||
return initPromise.then(function () { | ||
return handler = callback; | ||
}); | ||
} | ||
}; | ||
} | ||
@@ -96,0 +96,0 @@ |
{ | ||
"name": "resolve-bus-rabbitmq", | ||
"version": "0.4.1-0124084142.beta", | ||
"version": "0.4.1-0124150146.beta", | ||
"description": "This package is an adapter for resolve-bus to emit events using RabbitMQ.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
5001