Comparing version 0.0.9 to 0.0.10
'use strict' | ||
var Resourcer = require(__dirname + '/resourcer.js') | ||
var Resourcer = require('./resourcer.js') | ||
module.exports = { | ||
start: function (options) { | ||
var resourcer = Resourcer(options) | ||
resourcer.connect() | ||
return resourcer | ||
return Resourcer(options).connect() | ||
} | ||
} |
// Keeping it simple. The default logger only logs (at any level) | ||
// if debug is true. In error cases, where you might assume we should alwasy log | ||
// if debug is true. In error cases, where you might assume we should always log | ||
// the errors are emitted so the consuming code has an opportunity to handle. | ||
@@ -5,0 +5,0 @@ module.exports = function Logger (debug) { |
@@ -6,3 +6,3 @@ 'use strict' | ||
var deap = require('deap') | ||
var retry = require('./retry.js') | ||
var Retry = require('./retry') | ||
@@ -15,2 +15,3 @@ module.exports = function Resourcer (config) { | ||
var resourcer = new EventEmitter2({wildcard: true}) | ||
var retry = Retry() | ||
@@ -24,2 +25,4 @@ resourcer.connect = function (inWs) { | ||
.on('error', handledError) | ||
return resourcer | ||
} | ||
@@ -42,7 +45,5 @@ | ||
if (ws) { | ||
ws | ||
.removeAllListeners(handledOpen) | ||
.removeAllListeners(handledError) | ||
.removeAllListeners(handledClose) | ||
.removeAllListeners(handledMessage) | ||
ws.removeAllListeners() | ||
// this is a noop if already closed | ||
ws.close() | ||
} | ||
@@ -58,2 +59,3 @@ | ||
log.error('Invalid BEEPBOOP_RESOURCER environment variable value:', config.serverURL, e.toString()) | ||
// Exit process, this only occurs if the serverURL isn't a valid url | ||
process.exit(1) | ||
@@ -74,3 +76,3 @@ } | ||
if (err) { | ||
ws.emit('error', err) | ||
handledError(err) | ||
log.error('Authorization to the Beep Boop Server failed with:', err.toString()) | ||
@@ -82,2 +84,4 @@ } | ||
log.debug('Web Socket connection opened to Beep Boop Server:', config.serverURL) | ||
// Reset retry backoff | ||
retry = Retry() | ||
} | ||
@@ -95,3 +99,3 @@ | ||
retry.attempt(resourcer.connect) | ||
retry(resourcer.connect) | ||
} | ||
@@ -102,3 +106,4 @@ | ||
log.debug('Connection to Beep Boop server closed.', code, message) | ||
retry.attempt(resourcer.connect) | ||
retry(resourcer.connect) | ||
} | ||
@@ -105,0 +110,0 @@ |
@@ -8,9 +8,14 @@ var Back = require('back') | ||
var backAttempt | ||
var back | ||
function attempt (cb) { | ||
var back = backAttempt || (backAttempt = new Back(options)) | ||
return back.backoff(cb) | ||
module.exports = function () { | ||
if (back) { | ||
back.close() | ||
} | ||
back = new Back(options) | ||
return function retry (cb) { | ||
back.backoff(cb) | ||
} | ||
} | ||
module.exports.attempt = attempt |
{ | ||
"name": "beepboop", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "beepboop eases hosting a botkit based bot on the beepboop hosting platform.", | ||
"main": "lib/beepboop.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha test" | ||
}, | ||
@@ -32,3 +32,7 @@ "homepage": "http://beepboophq.com", | ||
"ws": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.4.5", | ||
"sinon": "^1.17.3" | ||
} | ||
} |
@@ -6,3 +6,2 @@ var events = require('events') | ||
var Resourcer = require(__dirname + '/../lib/resourcer.js') | ||
var retry = require(__dirname + '/../lib/retry.js') | ||
@@ -9,0 +8,0 @@ describe('Resourcer', 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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
250
2
4
12631
2
1