amqp-wrapper
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -82,2 +82,3 @@ var amqp = require('amqplib'), | ||
exports.publishToQueue = function(name, message, callback) { | ||
if (typeof message === 'object') message = JSON.stringify(message); | ||
var publishQueue = _.find(queueParams.publish, {'name': name}); | ||
@@ -97,2 +98,3 @@ channel.publish(exchange, publishQueue.routingKey, new Buffer(message), | ||
exports.publish = function(routingKey, message, options, callback) { | ||
if (typeof message === 'object') message = JSON.stringify(message); | ||
channel.publish(exchange, routingKey, new Buffer(message), options, callback); | ||
@@ -99,0 +101,0 @@ }; |
{ | ||
"name": "amqp-wrapper", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "A wrapper around https://github.com/squaremo/amqp.node to make consuming and publishing dead easy.", | ||
@@ -5,0 +5,0 @@ "main": "amqp.js", |
@@ -56,2 +56,4 @@ amqp-wrapper | ||
AMQP.publish(routingKey, payload, done); | ||
If `payload` is an object, it will be turned into JSON. | ||
``` | ||
@@ -58,0 +60,0 @@ |
@@ -23,6 +23,3 @@ var SandboxedModule = require('sandboxed-module'), | ||
] | ||
}, function(err, res) { | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}, done); | ||
}); | ||
@@ -39,3 +36,3 @@ it('should setup for publishing and consuming', function(done) { | ||
] | ||
}, function(err, res) { | ||
}, function(err) { | ||
if (err) return done(err); | ||
@@ -61,6 +58,3 @@ expect(AMQP.getSetupFuncs().consume.calledOnce, 'setupForConsume()').to. | ||
if (err) return done(err); | ||
AMQP.publishToQueue('myqueue', new Buffer('test'), function(err) { | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
AMQP.publishToQueue('myqueue', 'test', done); | ||
}); | ||
@@ -74,8 +68,12 @@ }); | ||
if (err) return done(err); | ||
AMQP.publish('myqueue', new Buffer('test'), {}, function(err) { | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
AMQP.publish('myqueue', 'test', {}, done); | ||
}); | ||
}); | ||
it('should accept objects', function(done) { | ||
AMQP.connect('amqp://guest:guest@localhost', 'mytestexchange', {}, | ||
function(err, res) { | ||
if (err) return done(err); | ||
AMQP.publish('myqueue', {woo: 'test'}, {}, done); | ||
}); | ||
}); | ||
}); | ||
@@ -82,0 +80,0 @@ describe('#consume', function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13692
84