Comparing version 2.3.2 to 2.3.3
@@ -0,1 +1,5 @@ | ||
2.3.3 | ||
----- | ||
* Add an early error if timeouts aren't numbers - @jkrems #33 | ||
2.3.2 | ||
@@ -2,0 +6,0 @@ ----- |
@@ -34,3 +34,3 @@ // Generated by CoffeeScript 1.9.0 | ||
*/ | ||
var DefaultPromise, EventEmitter, HRDuration, Hub, debug, extend, formatUri, generateHeaders, generateUUID, http, https, isJsonResponse, map, promiseHelpers, request, safeParseJSON, uuid, _ref, _ref1, _ref2; | ||
var DefaultPromise, EventEmitter, HRDuration, Hub, checkTimeout, debug, extend, formatUri, generateHeaders, generateUUID, http, https, isJsonResponse, map, promiseHelpers, request, safeParseJSON, util, uuid, _ref, _ref1, _ref2; | ||
@@ -43,2 +43,4 @@ EventEmitter = require('events').EventEmitter; | ||
util = require('util'); | ||
request = require('request'); | ||
@@ -60,2 +62,9 @@ | ||
checkTimeout = function(timeout) { | ||
if (typeof timeout !== 'number') { | ||
throw new Error(util.format('Invalid timeout: %j, not a number', timeout)); | ||
} | ||
return timeout; | ||
}; | ||
module.exports = Hub = function() { | ||
@@ -66,8 +75,7 @@ var hub, logPendingRequests, setupCompletionTimeout, setupTimeouts; | ||
hub.fetch = function(options, done) { | ||
var baseLog, completionTimeoutInterval, connectTimeoutInterval, fetchId, getSeconds, handleResult, hubHeaders, req, responseData, sendResult, _ref3; | ||
var baseLog, completionTimeoutInterval, connectTimeoutInterval, fetchId, getSeconds, handleResult, hubHeaders, req, responseData, sendResult, _ref3, _ref4; | ||
getSeconds = HRDuration().getSeconds; | ||
fetchId = generateUUID(); | ||
if (options.timeout == null) { | ||
options.timeout = Hub.requestTimeout; | ||
} | ||
options.timeout = checkTimeout((_ref3 = options.timeout) != null ? _ref3 : Hub.requestTimeout); | ||
connectTimeoutInterval = checkTimeout((_ref4 = options.connectTimeout) != null ? _ref4 : Hub.connectTimeout); | ||
if (options.headers == null) { | ||
@@ -93,6 +101,6 @@ options.headers = {}; | ||
handleResult = function(error, response, body) { | ||
var apiError, logLine, maxStatusCode, minStatusCode, parseJSON, successfulRequest, uri, _ref3, _ref4, _ref5; | ||
parseJSON = (_ref3 = options.parseJSON) != null ? _ref3 : isJsonResponse(response, body); | ||
var apiError, logLine, maxStatusCode, minStatusCode, parseJSON, successfulRequest, uri, _ref5, _ref6, _ref7; | ||
parseJSON = (_ref5 = options.parseJSON) != null ? _ref5 : isJsonResponse(response, body); | ||
if (parseJSON) { | ||
_ref4 = safeParseJSON(body, response), error = _ref4.error, body = _ref4.body; | ||
_ref6 = safeParseJSON(body, response), error = _ref6.error, body = _ref6.body; | ||
} | ||
@@ -122,3 +130,3 @@ responseData.fetchDuration = getSeconds(); | ||
maxStatusCode = options.maxStatusCode || 299; | ||
successfulRequest = (minStatusCode <= (_ref5 = response.statusCode) && _ref5 <= maxStatusCode); | ||
successfulRequest = (minStatusCode <= (_ref7 = response.statusCode) && _ref7 <= maxStatusCode); | ||
if (successfulRequest) { | ||
@@ -144,3 +152,2 @@ debug('<- %s', response.statusCode, uri); | ||
req = request(options, handleResult); | ||
connectTimeoutInterval = (_ref3 = options.connectTimeout) != null ? _ref3 : Hub.connectTimeout; | ||
completionTimeoutInterval = options.completionTimeout; | ||
@@ -147,0 +154,0 @@ setupTimeouts(connectTimeoutInterval, completionTimeoutInterval, req, responseData, getSeconds); |
{ | ||
"name": "gofer", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"description": "A general purpose service client library for node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/gofer.js", |
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
58332
837