Comparing version 2.0.0 to 2.1.0
19
API.md
@@ -255,2 +255,3 @@ | ||
3. All timings are reported in seconds with microtime precision. | ||
4. Data added to `options.logData` will be added to `start`, `fetchError`, `success` and `failure` messages. | ||
@@ -267,3 +268,9 @@ | ||
requestId: UUID, // id of the overall transaction | ||
fetchId: UUID } // id of this specific http call | ||
fetchId: UUID, // id of this specific http call | ||
uri: String, // the URI requested | ||
method: String, // uppercase HTTP verb, PUT/GET/... | ||
serviceName: String, // Config key ex: github | ||
endpointName: String, // Function name ex: repos | ||
methodName: String, // Defaults to lowercase HTTP verb but configurable per request | ||
pathParams: Object } // key/value pairs used in {tag} replacement | ||
``` | ||
@@ -305,3 +312,6 @@ | ||
requestId: UUID, | ||
fetchId: UUID } | ||
fetchId: UUID, | ||
serviceName: String, | ||
endpointName: String, | ||
pathParams: Object } | ||
``` | ||
@@ -318,3 +328,6 @@ | ||
syscall: String, // the syscall that failed (e.g. getaddrinfo) | ||
error: error } // the raw error object | ||
error: error, // the raw error object | ||
serviceName: String, | ||
endpointName: String, | ||
pathParams: Object } | ||
``` | ||
@@ -321,0 +334,0 @@ |
@@ -35,3 +35,3 @@ /* | ||
void function () { | ||
var applyBaseUrl, buildUserAgent, cache$, cache$1, Gofer, Hub, isJsonResponse, merge, parseDefaults, replacePathParms, resolveOptional, safeParseJSON; | ||
var applyBaseUrl, buildUserAgent, cache$, cache$1, extend, Gofer, Hub, isJsonResponse, merge, parseDefaults, resolveOptional, safeParseJSON; | ||
Hub = require('./hub'); | ||
@@ -43,3 +43,2 @@ cache$ = require('./helpers'); | ||
buildUserAgent = cache$.buildUserAgent; | ||
replacePathParms = cache$.replacePathParms; | ||
merge = cache$.merge; | ||
@@ -49,2 +48,3 @@ cache$1 = require('./json'); | ||
isJsonResponse = cache$1.isJsonResponse; | ||
extend = require('lodash').extend; | ||
Gofer = function () { | ||
@@ -185,3 +185,2 @@ function Gofer(config, param$) { | ||
defaults = this._getDefaults(this.defaults, options); | ||
options.uri = replacePathParms(options.uri, options.pathParams); | ||
if (null != options.methodName) | ||
@@ -218,2 +217,12 @@ options.methodName; | ||
} | ||
if (null != options.logData) | ||
options.logData; | ||
else | ||
options.logData = {}; | ||
extend({ | ||
serviceName: options.serviceName, | ||
endpointName: options.endpointName, | ||
methodName: options.methodName, | ||
pathParams: options.pathParams | ||
}, options.logData); | ||
return this.hub.fetch(options, function (err, body, response, responseData) { | ||
@@ -220,0 +229,0 @@ var data, parseJSON; |
@@ -35,3 +35,3 @@ /* | ||
void function () { | ||
var cache$, cloneDeep, isObject, merge, mergeSafe, reduce, Url; | ||
var cache$, cloneDeep, isObject, merge, mergeSafe, reduce, replacePathParams, Url; | ||
cache$ = require('lodash'); | ||
@@ -100,3 +100,3 @@ merge = cache$.merge; | ||
search = cache$2.search; | ||
options.uri = Url.format({ | ||
uri = Url.format({ | ||
protocol: protocol, | ||
@@ -109,2 +109,3 @@ hostname: hostname, | ||
}); | ||
options.uri = replacePathParams(uri, options.pathParams); | ||
return options; | ||
@@ -122,3 +123,3 @@ }; | ||
}; | ||
this.replacePathParms = function (uri, pathParams) { | ||
replacePathParams = function (uri, pathParams) { | ||
var regex, wrappedPathParams, wrappedTags; | ||
@@ -125,0 +126,0 @@ if (!isObject(pathParams)) |
@@ -50,3 +50,3 @@ /* | ||
hub.fetch = function (options, cb) { | ||
var completionTimeoutInterval, connectTimeoutInterval, fetchId, fetchStart, hubHeaders, req, responseData; | ||
var baseLog, completionTimeoutInterval, connectTimeoutInterval, fetchId, fetchStart, hubHeaders, req, responseData; | ||
fetchStart = microtime.nowDouble(); | ||
@@ -70,7 +70,11 @@ fetchId = generateUUID(); | ||
requestOptions: options, | ||
requestId: null != options ? options.requestId : void 0, | ||
requestId: options.requestId, | ||
fetchId: fetchId | ||
}; | ||
debug('-> %s', options.method, options.uri); | ||
hub.emit('start', responseData); | ||
baseLog = extend({ | ||
uri: options.uri, | ||
method: options.method | ||
}, options.logData); | ||
hub.emit('start', extend(baseLog, responseData)); | ||
req = request(options, function (error, response, body) { | ||
@@ -82,3 +86,3 @@ var apiError, logLine, maxStatusCode, minStatusCode, successfulRequest, uri; | ||
uri = formatUri(responseData.requestOptions.uri); | ||
logLine = { | ||
logLine = extend({ | ||
statusCode: null != response ? response.statusCode : void 0, | ||
@@ -89,5 +93,5 @@ uri: uri, | ||
fetchDuration: responseData.fetchDuration, | ||
requestId: null != options ? options.requestId : void 0, | ||
requestId: options.requestId, | ||
fetchId: fetchId | ||
}; | ||
}, options.logData); | ||
if (null != error) { | ||
@@ -94,0 +98,0 @@ logLine.syscall = error.syscall; |
{ | ||
"name": "gofer", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A general purpose service client library for node.js", | ||
@@ -37,2 +37,3 @@ "main": "lib/gofer.js", | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org", | ||
"license": { | ||
@@ -39,0 +40,0 @@ "exclude": [ |
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
48204
645