New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

resolve-bus-rabbitmq

Package Overview
Dependencies
Maintainers
1
Versions
603
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-bus-rabbitmq - npm Package Compare versions

Comparing version 0.13.2 to 0.14.0

dist/index.js.map

295

dist/index.js

@@ -14,2 +14,16 @@ "use strict";

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
var _amqplib = _interopRequireDefault(require("amqplib"));

@@ -26,43 +40,100 @@

function init(_ref, handler) {
var url = _ref.url,
exchange = _ref.exchange,
exchangeType = _ref.exchangeType,
queueName = _ref.queueName,
messageTtl = _ref.messageTtl,
maxLength = _ref.maxLength;
return _amqplib.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
var RabbitMQBusError =
/*#__PURE__*/
function (_Error) {
(0, _inherits2.default)(RabbitMQBusError, _Error);
function RabbitMQBusError(message, cause) {
var _this;
(0, _classCallCheck2.default)(this, RabbitMQBusError);
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(RabbitMQBusError).call(this));
_this.name = 'RabbitMQ Bus Error';
_this.message = message;
if (cause) {
_this.cause = cause;
}
return _this;
}
return RabbitMQBusError;
}((0, _wrapNativeSuper2.default)(Error));
var _init =
/*#__PURE__*/
function () {
var _ref2 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(_ref, handler) {
var url, exchange, exchangeType, queueName, messageTtl, maxLength, connection, channel, queue;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
url = _ref.url, exchange = _ref.exchange, exchangeType = _ref.exchangeType, queueName = _ref.queueName, messageTtl = _ref.messageTtl, maxLength = _ref.maxLength;
_context.prev = 1;
_context.next = 4;
return _amqplib.default.connect(url);
case 4:
connection = _context.sent;
_context.next = 7;
return connection.createChannel();
case 7:
channel = _context.sent;
_context.next = 10;
return channel.assertExchange(exchange, exchangeType, {
durable: false
});
case 10:
_context.next = 12;
return channel.assertQueue(queueName, {
arguments: {
messageTtl: messageTtl,
maxLength: maxLength
}
});
case 12:
queue = _context.sent;
_context.next = 15;
return channel.bindQueue(queue.queue, exchange);
case 15:
_context.next = 17;
return channel.consume(queueName, function (msg) {
if (msg) {
var content = msg.content.toString();
var message = JSON.parse(content);
handler(message);
}
}, {
noAck: true
});
case 17:
return _context.abrupt("return", channel);
case 20:
_context.prev = 20;
_context.t0 = _context["catch"](1);
throw new RabbitMQBusError(_context.t0.message, _context.t0.cause);
case 23:
case "end":
return _context.stop();
}
}
}).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;
});
});
}
}, _callee, this, [[1, 20]]);
}));
return function init(_x, _x2) {
return _ref2.apply(this, arguments);
};
}();
function createAdapter(options) {

@@ -72,5 +143,3 @@ var handler = function handler() {};

var config = (0, _objectSpread2.default)({}, defaultOptions, options);
var initPromise = init(config, function (event) {
return handler(event);
});
var initPromise = null;
var exchange = config.exchange,

@@ -80,17 +149,126 @@ queueName = config.queueName,

return {
publish: function publish(event) {
return initPromise.then(function (channel) {
channel.publish(exchange, queueName, new Buffer((0, _stringify.default)(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;
});
}
init: function () {
var _init2 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee2() {
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (!initPromise) {
initPromise = _init(config, function (event) {
return handler(event);
});
}
_context2.prev = 1;
_context2.next = 4;
return initPromise;
case 4:
return _context2.abrupt("return", _context2.sent);
case 7:
_context2.prev = 7;
_context2.t0 = _context2["catch"](1);
initPromise = null;
throw _context2.t0;
case 11:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[1, 7]]);
}));
return function init() {
return _init2.apply(this, arguments);
};
}(),
publish: function () {
var _publish = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee3(event) {
var channel;
return _regenerator.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
if (initPromise) {
_context3.next = 2;
break;
}
throw new RabbitMQBusError('Adapter is not initialized');
case 2:
_context3.next = 4;
return initPromise;
case 4:
channel = _context3.sent;
return _context3.abrupt("return", channel.publish(exchange, queueName, new Buffer((0, _stringify.default)(event)), // Additional options described here:
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish
{
expiration: messageTtl,
persistent: false
}));
case 6:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
return function publish(_x3) {
return _publish.apply(this, arguments);
};
}(),
subscribe: function () {
var _subscribe = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee4(callback) {
return _regenerator.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
return _context4.abrupt("return", handler = callback);
case 1:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
return function subscribe(_x4) {
return _subscribe.apply(this, arguments);
};
}(),
close: function () {
var _close = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee5() {
return _regenerator.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
initPromise = null;
case 1:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
return function close() {
return _close.apply(this, arguments);
};
}()
};

@@ -100,2 +278,3 @@ }

var _default = createAdapter;
exports.default = _default;
exports.default = _default;
//# sourceMappingURL=index.js.map

20

package.json
{
"name": "resolve-bus-rabbitmq",
"version": "0.13.2",
"version": "0.14.0",
"description": "This package is an adapter for resolve-bus to emit events using RabbitMQ.",

@@ -10,5 +10,5 @@ "main": "./dist/index.js",

"scripts": {
"prepublish": "babel --out-dir ./dist ./src",
"test": "jest --testMatch=**/test/*.tests.js",
"testw": "jest --testMatch=**/test/*.tests.js --watchAll"
"prepare": "babel --config-file=../../../../.babelrc --source-maps --out-dir ./dist ./src",
"test": "jest --config=../../../../jest.config.js --verbose",
"testw": "jest --config=../../../../jest.config.js --watchAll"
},

@@ -29,15 +29,5 @@ "repository": "https://github.com/reimagined/resolve.git",

"devDependencies": {
"@babel/cli": "7.0.0-beta.54",
"@babel/core": "7.0.0-beta.54",
"@babel/plugin-transform-runtime": "7.0.0-beta.54",
"@babel/preset-env": "7.0.0-beta.54",
"@babel/preset-react": "7.0.0-beta.54",
"@babel/preset-stage-0": "7.0.0-beta.54",
"babel-core": "^7.0.0-0",
"babel-jest": "23.4.0",
"regenerator-runtime": "0.12.0",
"jest": "23.4.1",
"chai": "^4.1.2",
"jest": "23.4.2",
"sinon": "^6.1.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc