Skip to content

Commit 526ece2

Browse files
committed
Nodes updated to use new url based services utility
1 parent 3c88163 commit 526ece2

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

services/alchemy_date_extraction/v1.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
module.exports = function (RED) {
1818
const SERVICE_IDENTIFIER = 'gateway-a.watsonplatform.net';
19-
var watson = require('watson-developer-cloud');
20-
21-
var payloadutils = require('../../utilities/payload-utils'),
22-
serviceutils = require('../../utilities/service-utils');
19+
var watson = require('watson-developer-cloud'),
20+
payloadutils = require('../../utilities/payload-utils'),
21+
serviceutils = require('../../utilities/service-utils'),
22+
apikey, s_apikey,
23+
service = serviceutils.getServiceCredsAlchemy(SERVICE_IDENTIFIER);
2324

2425
// Require the Cloud Foundry Module to pull credentials from bound service
2526
// If they are found then the api key is stored in the variable s_apikey.
@@ -30,14 +31,6 @@ module.exports = function (RED) {
3031
// user who, when he errenously enters bad credentials, can't figure out why
3132
// the edited ones are not being taken.
3233

33-
// Taking this line out as codacy was complaining about it.
34-
// var services = cfenv.getAppEnv().services;
35-
var service;
36-
37-
var apikey, s_apikey;
38-
39-
var service = serviceutils.getServiceCredsAlchemy(SERVICE_IDENTIFIER);
40-
4134
if (service) {
4235
s_apikey = service.apikey;
4336
}

services/alchemy_language/v1.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ module.exports = function (RED) {
3838
var watson = require('watson-developer-cloud');
3939

4040
var payloadutils = require('../../utilities/payload-utils'),
41-
serviceutils = require('../../utilities/service-utils');
41+
serviceutils = require('../../utilities/service-utils'),
42+
apikey, s_apikey,
43+
service = serviceutils.getServiceCredsAlchemy(SERVICE_IDENTIFIER);
4244

4345

4446
// Require the Cloud Foundry Module to pull credentials from bound service
@@ -50,14 +52,6 @@ module.exports = function (RED) {
5052
// user who, when he errenously enters bad credentials, can't figure out why
5153
// the edited ones are not being taken.
5254

53-
// Taking this line out as codacy was complaining about it.
54-
// var services = cfenv.getAppEnv().services;
55-
var service;
56-
57-
var apikey, s_apikey;
58-
59-
var service = serviceutils.getServiceCredsAlchemy(SERVICE_IDENTIFIER);
60-
6155
if (service) {
6256
s_apikey = service.apikey;
6357
}

utilities/service-utils.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ ServiceUtils.prototype = {
2323
// that the url associated with the service, contains the matched
2424
// input value, hence reducing the chances of a false match.
2525
checkCFForService: function(serviceName, returnBoolean, alchemyRegex) {
26-
var regex = alchemyRegex ? RegExp('(http|https)(://)('+serviceName+').*')
27-
: RegExp('(http|https)(://)([^\/]+)(/)('+serviceName+').*');
26+
var regex = alchemyRegex ?
27+
RegExp('(http|https)(://)('+serviceName+').*') :
28+
RegExp('(http|https)(://)([^\/]+)(/)('+serviceName+').*');
2829

2930
var services = appEnv.getServices();
3031

0 commit comments

Comments
 (0)