loopback-bluemix
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -96,3 +96,19 @@ // Copyright IBM Corp. 2017. All Rights Reserved. | ||
} | ||
request(httpReq, cb); | ||
request(httpReq, function(err, res) { | ||
if (err) return cb(err); | ||
if (res.statusCode >= 300) { | ||
var errObj = {}; | ||
if (res.body && typeof res.body === 'object') { | ||
errObj = res.body; | ||
} | ||
var msg = errObj.description || ('Bluemix api error: ' + res.statusCode); | ||
err = new Error(msg); | ||
for (var i in errObj) { | ||
err[i] = res.body[i]; | ||
} | ||
cb(err); | ||
} else { | ||
cb(err, res); | ||
} | ||
}); | ||
} | ||
@@ -407,2 +423,3 @@ | ||
getServices(parent, accessToken, options, function(err, services) { | ||
if (err) return cb(err); | ||
var supportedServices = {}; | ||
@@ -409,0 +426,0 @@ services.forEach(function(resource) { |
@@ -13,3 +13,2 @@ // Copyright IBM Corp. 2017. All Rights Reserved. | ||
var cf = require('./cf'); | ||
var cfConfig = cf.getCfConfig(); | ||
var templatesDir = path.resolve(__dirname, '..', 'templates'); | ||
@@ -22,2 +21,11 @@ var datasourcesConfigPath = path.join(templatesDir, 'bluemix', 'bluemix', | ||
var cfConfig; | ||
function getCfConfig() { | ||
if (cfConfig) return cfConfig; | ||
else { | ||
cfConfig = cf.getCfConfig(); | ||
return cfConfig; | ||
} | ||
} | ||
/** | ||
@@ -31,3 +39,3 @@ * Present Bluemix datasource selection options | ||
datasource.log('Finding Bluemix data service instances...'); | ||
cf.getDataServiceInstances(null, cfConfig.accessToken, | ||
cf.getDataServiceInstances(null, getCfConfig().accessToken, | ||
function(err, resources) { | ||
@@ -104,4 +112,6 @@ if (err) return done(err); | ||
datasource.name = answers.serviceName; | ||
datasource.connector = services[datasource.name].connector; | ||
datasource.serviceGUID = services[datasource.name].guid; | ||
var service = services[datasource.name]; | ||
if (!service) return done(new Error('Invalid service: ' + datasource.name)); | ||
datasource.connector = service.connector; | ||
datasource.serviceGUID = service.guid; | ||
} | ||
@@ -149,3 +159,3 @@ return done(); | ||
var done = datasource.async(); | ||
cf.getSupportedServices(null, cfConfig.accessToken, function(err, serviceDetails) { | ||
cf.getSupportedServices(null, getCfConfig().accessToken, function(err, serviceDetails) { | ||
if (err) return done(err); | ||
@@ -166,3 +176,3 @@ datasource.dataServices = serviceDetails; | ||
datasource.servicePlans = {}; | ||
cf.getServicePlans(null, cfConfig.accessToken, service.plansUrl, | ||
cf.getServicePlans(null, getCfConfig().accessToken, service.plansUrl, | ||
function(err, servicePlans) { | ||
@@ -197,4 +207,4 @@ if (err) return done(err); | ||
details['service_plan_guid'] = datasource.servicePlans[answers.servicePlan]; | ||
details['space_guid'] = cfConfig.space.guid; | ||
cf.provisionService(cfConfig.accessToken, details, function(err, res, service) { | ||
details['space_guid'] = getCfConfig().space.guid; | ||
cf.provisionService(getCfConfig().accessToken, details, function(err, res, service) { | ||
if (err) return done(err); | ||
@@ -213,3 +223,3 @@ datasource.serviceGUID = service.metadata.guid; | ||
var done = datasource.async(); | ||
cf.getApps(null, cfConfig.accessToken, function(err, resources) { | ||
cf.getApps(null, getCfConfig().accessToken, function(err, resources) { | ||
if (err) return done(err); | ||
@@ -225,3 +235,3 @@ var matchedApp = false; | ||
}; | ||
cf.bindService(cfConfig.accessToken, details, function(err) { | ||
cf.bindService(getCfConfig().accessToken, details, function(err) { | ||
return done(err); | ||
@@ -228,0 +238,0 @@ }); |
{ | ||
"name": "loopback-bluemix", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Utilities for generating generate Bluemix artefacts", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
87525
13
30
1023
1