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

larvituser

Package Overview
Dependencies
Maintainers
3
Versions
265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvituser - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

120

dataWriter.js

@@ -10,2 +10,3 @@ 'use strict';

uuidLib = require('uuid'),
checkKey = require('check-object-key'),
lUtils = require('larvitutils'),

@@ -168,62 +169,2 @@ amsync = require('larvitamsync'),

function checkIntercom(firstRun, cb) {
const logPrefix = topLogPrefix + 'checkIntercom() - ';
if (typeof firstRun === 'function') {
cb = firstRun;
firstRun = true;
} else if (firstRun === undefined) {
firstRun = true;
cb = function () {};
}
if (exports.intercom instanceof Intercom) {
log.debug(logPrefix + 'exports.intercom is set, no modification needed');
} else if (lUtils.instances.intercom instanceof Intercom) {
log.info(logPrefix + 'Using larvitutils.instances.intercom as Intercom');
exports.intercom = lUtils.instances.intercom;
} else if (firstRun === false) {
log.warn(logPrefix + 'Neither exports.intercom nor larvitutils.instances.intercom is an instance of Intercom. Fallback to create our own loopback interface.');
exports.intercom = new Intercom('loopback interface');
} else {
// Give the app 50ms to sort this shit out before we use the fallback fallback
setTimeout(function () {
checkIntercom(false, cb);
}, 50);
return;
}
cb();
}
function checkMode(firstRun, cb) {
const logPrefix = topLogPrefix + 'checkMode() - ';
if (typeof firstRun === 'function') {
cb = firstRun;
firstRun = true;
} else if (firstRun === undefined) {
firstRun = true;
cb = function () {};
}
if (exports.mode === 'slave' || exports.mode === 'master' || exports.mode === 'noSync') {
log.debug(logPrefix + 'exports.mode is set, no modification needed');
} else if (lUtils.instances.dataWriterMode !== undefined) {
log.info(logPrefix + 'Using larvitutils.instances.dataWriterMode as mode');
exports.mode = lUtils.instances.dataWriterMode;
} else if (firstRun === false) {
log.warn(logPrefix + 'Neither exports.mode nor larvitutils.instances.dataWriterMode is set to a valid string. Falling back to noSync.');
exports.mode = 'noSync';
} else {
// Give the app 50ms to sort this shit out before we use the fallback fallback
setTimeout(function () {
checkMode(false, cb);
}, 50);
return;
}
cb();
}
function create(params, deliveryTag, msgUuid, cb) {

@@ -299,12 +240,33 @@ const logPrefix = topLogPrefix + 'create() - ',

tasks.push(checkIntercom);
tasks.push(checkMode);
tasks.push(function (cb) {
checkKey({
'obj': exports,
'objectKey': 'mode',
'validValues': ['master', 'slave', 'noSync'],
'default': 'noSync'
}, function (err, warning) {
if (warning) log.warn(logPrefix + warning);
cb(err);
});
});
tasks.push(function (cb) {
checkKey({
'obj': exports,
'objectKey': 'intercom',
'default': new Intercom('loopback interface'),
'defaultLabel': 'loopback interface'
}, function (err, warning) {
if (warning) log.warn(logPrefix + warning);
cb(err);
});
});
tasks.push(function (cb) {
if (exports.mode === 'master') {
listenMethod = 'consume';
options.exclusive = true; // It is important no other client tries to sneak
// out messages from us, and we want "consume"
// since we want the queue to persist even if this
// minion goes offline.
// // out messages from us, and we want "consume"
// // since we want the queue to persist even if this
// // minion goes offline.
} else if (exports.mode === 'slave' || exports.mode === 'noSync') {

@@ -385,6 +347,27 @@ listenMethod = 'subscribe';

tasks.push(checkIntercom);
tasks.push(checkMode);
tasks.push(function (cb) {
checkKey({
'obj': exports,
'objectKey': 'mode',
'validValues': ['master', 'slave', 'noSync'],
'default': 'noSync'
}, function (err, warning) {
if (warning) log.warn(logPrefix + warning);
cb(err);
});
});
tasks.push(function (cb) {
checkKey({
'obj': exports,
'objectKey': 'intercom',
'default': new Intercom('loopback interface'),
'defaultLabel': 'loopback interface'
}, function (err, warning) {
if (warning) log.warn(logPrefix + warning);
cb(err);
});
});
tasks.push(function (cb) {
if (exports.mode === 'both' || exports.mode === 'slave') {

@@ -609,3 +592,4 @@ log.verbose(logPrefix + 'exports.mode: "' + exports.mode + '", so read');

options['Content-Type'] = 'application/sql';
options['Content-Type'] = 'application/sql';
options.intercom = exports.intercom;

@@ -612,0 +596,0 @@ new amsync.SyncServer(options, cb);

@@ -6,4 +6,3 @@ 'use strict';

let dataWriter,
intercom;
let dataWriter;

@@ -60,3 +59,3 @@ /**

intercom.send(sendObj, options, function (err) {
dataWriter.intercom.send(sendObj, options, function (err) {
if (err) { cb(err); return; }

@@ -76,10 +75,3 @@

dataWriter = require(__dirname + '/dataWriter.js'); // We must do this here since it might not be instanciated on module load
dataWriter.ready(function (err) {
if (err) return cb(err);
intercom = lUtils.instances.intercom; // We must do this here since it might not be instanciated on module load
cb();
});
dataWriter.ready(cb);
}

@@ -86,0 +78,0 @@

{
"name": "larvituser",
"version": "0.11.0",
"version": "0.12.0",
"author": {

@@ -13,4 +13,5 @@ "name": "Mikael 'Lilleman' Göransson",

"bcryptjs": "^2.3.0",
"check-object-key": "^0.1.2",
"larvitamintercom": "^0.2.0",
"larvitamsync": "^0.3.0",
"larvitamsync": "^0.5.1",
"larvitdb": "^1.0.0",

@@ -25,4 +26,4 @@ "larvitdbmigration": "^2.0.0",

"freeport": "^1.0.5",
"mocha": "^3.1.0",
"mocha-eslint": "^3.0.1"
"mocha": "^4.0.1",
"mocha-eslint": "^4.1.0"
},

@@ -29,0 +30,0 @@ "scripts": {

@@ -12,13 +12,9 @@ 'use strict';

userLib.dataWriter.mode = 'master';
// Set up winston
log.remove(log.transports.Console);
/**/log.add(log.transports.Console, {
'level': 'warn',
'colorize': true,
'timestamp': true,
'level': 'warn',
'json': false
});
/**/
}); /**/

@@ -29,2 +25,6 @@ before(function (done) {

// Setting intercom and mode
userLib.dataWriter.mode = 'master';
userLib.dataWriter.intercom = new Intercom('loopback interface');
// Run DB Setup

@@ -74,8 +74,2 @@ tasks.push(function (cb) {

// Setup intercom
tasks.push(function (cb) {
lUtils.instances.intercom = new Intercom('loopback interface');
lUtils.instances.intercom.on('ready', cb);
});
// Migrating user db etc

@@ -82,0 +76,0 @@ tasks.push(function (cb) {

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