Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

servicebus

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

servicebus - npm Package Compare versions

Comparing version 0.2.5 to 0.3.0

bus/middleware/logger.js

35

bus/bus.js
function Bus () {
this.middleware = [];
this.incomingMiddleware = [];
this.outgoingMiddleware = [];
}
Bus.prototype.use = function (middleware) {
this.middleware.push(middleware);
if (middleware.handleIncoming) this.incomingMiddleware.push(middleware.handleIncoming);
if (middleware.handleOutgoing) this.outgoingMiddleware.push(middleware.handleOutgoing);
return this;
}
Bus.prototype.handleIncoming = function (message, headers, deliveryInfo, messageHandle, options, callback) {
var stack = this.middleware, index = this.middleware.length - 1;
var stack = this.incomingMiddleware, index = this.incomingMiddleware.length - 1;

@@ -27,12 +28,7 @@ function next (err) {

if ( ! layer) {
if ( undefined === layer) {
return callback(message, headers, deliveryInfo, messageHandle, options);
}
if (layer.handleIncoming) {
layer.handleIncoming(message, headers, deliveryInfo, messageHandle, options, next);
} else {
next(null, message, headers, deliveryInfo, messageHandle, options);
layer(message, headers, deliveryInfo, messageHandle, options, next);
}
}

@@ -43,6 +39,5 @@

Bus.prototype.handleOutgoing = function (queueName, message, callback) {
var stack = this.middleware, index = 0;
var stack = this.outgoingMiddleware, index = 0;

@@ -61,11 +56,7 @@ function next (err) {

if ( ! layer) {
if ( undefined === layer) {
return callback(queueName, message);
}
if (layer.handleOutgoing) {
layer.handleOutgoing(queueName, message, next);
} else {
next(null, queueName, message);
}
} else {
layer(queueName, message, next);
}
}

@@ -77,3 +68,3 @@

Bus.prototype.correlate = require('./middleware/correlate');
Bus.prototype.log = require('./middleware/log');
Bus.prototype.logger = require('./middleware/logger');
Bus.prototype.package = require('./middleware/package');

@@ -80,0 +71,0 @@ Bus.prototype.retry = require('./middleware/retry');

@@ -9,3 +9,3 @@ {

"description": "Simple service bus for sending events between processes using amqp.",
"version": "0.2.5",
"version": "0.3.0",
"homepage": "https://github.com/mateodelnorte/servicebus",

@@ -12,0 +12,0 @@ "repository": {

@@ -125,5 +125,5 @@ # servicebus

### Log
### Logger
Log ensures that incoming and outgoing messages are logged to stdout via the debug module.
Logger ensures that incoming and outgoing messages are logged to stdout via the debug module. (Use this in non-high throughput scenarios, otherwise you'll have some very quickly growing logs)

@@ -130,0 +130,0 @@ ### Package

@@ -12,5 +12,5 @@ require('longjohn')

bus.use(bus.correlate());
bus.use(bus.log());
bus.use(bus.logger());
bus.use(bus.retry());
module.exports.bus = bus;
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