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

larvitamintercom

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvitamintercom - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

40

index.js
'use strict';
const EventEmitter = require('events').EventEmitter,
uuidLib = require('node-uuid'),
bramqp = require('bramqp'),
lUtils = require('larvitutils'),
async = require('async'),

@@ -207,2 +209,6 @@ log = require('winston'),

if (lUtils.formatUuid(message.uuid) === false) {
log.warn('larvitamintercom: consume() - Message does not contain uuid. deliveryTag: "' + deliveryTag + '" content: "' + content.toString() + '"');
}
msgCb(message, function(err) {

@@ -308,4 +314,12 @@ if (err) {

Intercom.prototype.send = function(message, options, cb) {
const tasks = [],
/**
* Send something
*
* @param obj message - message will be appended with an uuid if that does not exist
* @param obj options - OPTIONAL - options.exchange = str
* @param func cb(err, message assigned uuid)
*/
Intercom.prototype.send = function(orgMsg, options, cb) {
const message = require('util')._extend({}, orgMsg),
tasks = [],
that = this;

@@ -327,2 +341,6 @@

try {
if (message.uuid === undefined) {
message.uuid = uuidLib.v4();
}
stringifiedMsg = JSON.stringify(message);

@@ -336,3 +354,3 @@ } catch(err) {

log.debug('larvitamintercom: send() - Sending to exchange: "' + options.exchange + '", message: "' + stringifiedMsg + '"');
log.debug('larvitamintercom: send() - Sending to exchange: "' + options.exchange + '", uuid: "' + message.uuid + ', message: "' + stringifiedMsg + '"');

@@ -357,3 +375,3 @@ // Declare exchange

if (err) {
log.warn('larvitamintercom: send() - Could not publish to exchange: "' + options.exchange + '". err: ' + err.message + ' message: "' + stringifiedMsg + '"');
log.warn('larvitamintercom: send() - Could not publish to exchange: "' + options.exchange + '". err: ' + err.message + ', uuid: "' + message.uuid + ', message: "' + stringifiedMsg + '"');
cb(err);

@@ -363,3 +381,3 @@ return;

log.debug('larvitamintercom: send() - Published (no content sent) to exchange: "' + options.exchange + '", message: "' + stringifiedMsg + '"');
log.debug('larvitamintercom: send() - Published (no content sent) to exchange: "' + options.exchange + '", uuid: "' + message.uuid + ', message: "' + stringifiedMsg + '"');

@@ -378,6 +396,6 @@ cb();

if (err) {
log.warn('larvitamintercom: send() - Could not send publish content to exchange: "' + options.exchange + '". err: ' + err.message + ' message: "' + stringifiedMsg + '"');
log.warn('larvitamintercom: send() - Could not send publish content to exchange: "' + options.exchange + '". err: ' + err.message + ', uuid: "' + message.uuid + ', message: "' + stringifiedMsg + '"');
}
log.debug('larvitamintercom: send() - Content sent to exchange: "' + options.exchange + '", message: "' + stringifiedMsg + '"');
log.debug('larvitamintercom: send() - Content sent to exchange: "' + options.exchange + '", uuid: "' + message.uuid + ', message: "' + stringifiedMsg + '"');

@@ -388,3 +406,5 @@ cb(err);

async.series(tasks, cb);
async.series(tasks, function(err) {
cb(err, message.uuid);
});
};

@@ -473,2 +493,6 @@

if (lUtils.formatUuid(message.uuid) === false) {
log.warn('larvitamintercom: consume() - Message does not contain uuid. deliveryTag: "' + deliveryTag + '" content: "' + content.toString() + '"');
}
msgCb(message, function(err) {

@@ -475,0 +499,0 @@ if (err) {

7

package.json
{
"name": "larvitamintercom",
"version": "0.0.3",
"version": "0.1.0",
"description": "",

@@ -22,3 +22,4 @@ "main": "index.js",

"bramqp": "^0.5.0",
"uuid": "^2.0.3",
"larvitutils": "^1.0.4",
"node-uuid": "^1.4.7",
"winston": "^2.2.0"

@@ -28,5 +29,5 @@ },

"eslint": "^3.1.1",
"mocha": "^2.5.3",
"mocha": "^3.1.0",
"mocha-eslint": "^3.0.1"
}
}

@@ -21,6 +21,5 @@ [![Build Status](https://travis-ci.org/larvit/larvitamintercom.svg?branch=master)](https://travis-ci.org/larvit/larvitamintercom) [![Dependencies](https://david-dm.org/larvit/larvitamintercom.svg)](https://david-dm.org/larvit/larvitamintercom.svg)

intercom.send(message, options, function(err) {
intercom.send(message, options, function(err, msgUuid) {
// called when message is accepted by queue handler
}, function(err) {
// called when all consumeres have acked the message
// msgUuid will be a unique UUID for this specific message
});

@@ -60,5 +59,7 @@ ```

intercom.consume(options, function(message, ack) {
intercom.consume(options, function(message, ack, deliveryTag) {
// message being the object sent with intercom.send()
// deliveryTag is an identification of this delivery
// Must be ran! Always! ACK!!

@@ -91,5 +92,7 @@ ack();

intercom.subscribe(options, function(message, ack) {
intercom.subscribe(options, function(message, ack, deliveryTag) {
// message subscribe the object sent with intercom.send()
// deliveryTag is an identification of this delivery
// Must be ran! Always! ACK!!

@@ -96,0 +99,0 @@ ack();

@@ -5,4 +5,4 @@ 'use strict';

Intercom = require(__dirname + '/../index.js'),
//uuidLib = require('uuid'), // Used to make unique exchange and queue names
assert = require('assert'),
lUtils = require('larvitutils'),
async = require('async'),

@@ -109,2 +109,4 @@ log = require('winston'),

intercom.consume(function(msg, ack, deliveryTag) {
assert.notDeepEqual(lUtils.formatUuid(msg.uuid), false);
delete msg.uuid;
assert.deepEqual(JSON.stringify(orgMsg), JSON.stringify(msg));

@@ -119,2 +121,4 @@ assert(deliveryTag, 'deliveryTag shoult be non-empty');

intercom.subscribe(function(msg, ack, deliveryTag) {
assert.notDeepEqual(lUtils.formatUuid(msg.uuid), false);
delete msg.uuid;
assert.deepEqual(JSON.stringify(orgMsg), JSON.stringify(msg));

@@ -163,2 +167,4 @@ assert(deliveryTag, 'deliveryTag shoult be non-empty');

intercom.consume({'exchange': exchangeName}, function(msg, ack, deliveryTag) {
assert.notDeepEqual(lUtils.formatUuid(msg.uuid), false);
delete msg.uuid;
assert.deepEqual(JSON.stringify(orgMsg), JSON.stringify(msg));

@@ -173,2 +179,4 @@ assert(deliveryTag, 'deliveryTag shoult be non-empty');

intercom.subscribe({'exchange': exchangeName}, function(msg, ack, deliveryTag) {
assert.notDeepEqual(lUtils.formatUuid(msg.uuid), false);
delete msg.uuid;
assert.deepEqual(JSON.stringify(orgMsg), JSON.stringify(msg));

@@ -208,2 +216,4 @@ assert(deliveryTag, 'deliveryTag shoult be non-empty');

intercoms[10].subscribe({'exchange': exchangeName}, function(msg, ack, deliveryTag) {
assert.notDeepEqual(lUtils.formatUuid(msg.uuid), false);
delete msg.uuid;
assert.deepEqual(JSON.stringify(orgMsg), JSON.stringify(msg));

@@ -210,0 +220,0 @@ assert(deliveryTag, 'deliveryTag shoult be non-empty');

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