node-red-bluemix-nodes
Advanced tools
Comparing version 1.0.2 to 1.0.4
{ | ||
"name": "node-red-bluemix-nodes", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "A collection of extra Node-RED nodes for IBM Bluemix.", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -20,9 +20,14 @@ /** | ||
var services = cfenv.getAppEnv().services; | ||
var username, password, host = 'https://twcservice.mybluemix.net'; | ||
var service = cfenv.getAppEnv().getServiceCreds(/insights for weather/i); | ||
var username, password, host = 'https://twcservice.mybluemix.net', base_uri = '/api/weather/v1/geocode/'; | ||
var service; | ||
for (var i in services) { | ||
if (i.match(/^(weatherinsights)/i)) { | ||
service = services[i][0]; | ||
} | ||
} | ||
if (service) { | ||
username = service.username; | ||
password = service.password; | ||
host = 'https://' + service.host; | ||
username = service.credentials.username; | ||
password = service.credentials.password; | ||
host = 'https://' + service.credentials.host; | ||
} | ||
@@ -52,7 +57,7 @@ | ||
if (typeof msg.payload === 'string' && msg.payload.match(lat_long_regex)) { | ||
geocode = msg.payload; | ||
geocode = msg.payload.replace(',', '/'); | ||
} else if (typeof msg.location === 'object') { | ||
geocode = [msg.location.lat, msg.location.lon].join(','); | ||
geocode = [msg.location.lat, msg.location.lon].join('/'); | ||
} else if (config.geocode.match(lat_long_regex)) { | ||
geocode = config.geocode; | ||
geocode = config.geocode.replace(',', '/'); | ||
} else { | ||
@@ -67,3 +72,3 @@ var message2 = 'Missing valid latlong parameters on either msg.payload, msg.location or node config.'; | ||
node.status({fill:"blue", shape:"dot", text:"requesting"}); | ||
request({url: host + config.service, auth: {username: username, password: password}, qs: {geocode: geocode, units: config.units, language: config.language}}, function(error, response, body) { | ||
request({url: host + base_uri + geocode + config.service, auth: {username: username, password: password}, qs: {units: config.units, language: config.language}}, function(error, response, body) { | ||
node.status({}); | ||
@@ -70,0 +75,0 @@ if (!error && response.statusCode == 200) { |
Sorry, the diff of this file is not supported yet
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
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
116166
1177
2