nutritionix
Advanced tools
Comparing version 0.5.0 to 0.5.1
23
index.js
@@ -37,3 +37,20 @@ 'use strict'; | ||
return { | ||
var nutritionix = { | ||
$extend: function (endpoints, mapDefinitionFunction) { | ||
apiMap.map.$extend(mapDefinitionFunction); | ||
_.forEach(endpoints, function (endpoint) { | ||
var endpointRoute = (endpoint.name || endpoint.path).split('.'); | ||
var current = nutritionix; | ||
var routeKey = endpointRoute.pop(); | ||
_.forEach(endpointRoute, function (routeKey) { | ||
if (!current[routeKey]) { | ||
current[routeKey] = {}; | ||
} | ||
current = current[routeKey]; | ||
}); | ||
current[routeKey] = new apiMap.ApiRequest(endpoint.path, endpoint.payloadKey, endpoint.expectedStatus); | ||
}); | ||
}, | ||
search: new apiMap.ApiRequest('v2.search', 'json'), | ||
@@ -46,2 +63,4 @@ autocomplete: new apiMap.ApiRequest('v2.autocomplete', 'qs'), | ||
}; | ||
return nutritionix; | ||
} | ||
@@ -56,2 +75,2 @@ | ||
module.exports = Nutritionix; | ||
module.exports = Nutritionix; |
@@ -11,3 +11,3 @@ 'use strict'; | ||
var map = endpoints({ | ||
var map = this.map = endpoints({ | ||
header: { | ||
@@ -118,2 +118,2 @@ 'X-APP-ID': clientOpts.appId, | ||
module.exports = ApiMap; | ||
module.exports = ApiMap; |
@@ -7,2 +7,5 @@ 'use strict'; | ||
return { | ||
$extend: function(mapDefinitionFunction){ | ||
_.merge(this, mapDefinitionFunction(credentials, url) || {}); | ||
}, | ||
v2: { | ||
@@ -53,2 +56,2 @@ search: { | ||
}; | ||
}; | ||
}; |
{ | ||
"name": "nutritionix", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Official Nutritionix NodeJS Client Library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,8 +0,6 @@ | ||
Official Nutritionix NodeJS Client | ||
Nutritionix API v2.0 Beta NodeJS Client Library | ||
================================== | ||
#### NOTE This is still in beta and the API may change until version 1.0 of this library. | ||
#### NOTE This library is still in beta and subject to change. | ||
#### NOTE `v1` of the API is currently not yet implemented | ||
### Installation | ||
@@ -9,0 +7,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18656
349
0
99