From c45cc5990d7098865cbea2d279cc32b4df55c7ba Mon Sep 17 00:00:00 2001 From: Jeremy R Geddes Date: Sun, 29 Jan 2017 21:57:46 -0600 Subject: [PATCH 1/3] merge in fixes and changes for gateway director --- Dockerfile | 17 +++++++++++++++++ lib/analytics.js | 17 +++++++++-------- lib/api-loader/index.js | 9 ++++++++- lib/microgw.js | 3 +++ package.json | 4 ++-- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..762cf0a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM tatsushid/tinycore-node:6.6 +ENV NODE_ENV production + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +ENV REGISTRY http://9.10.79.72:4873/ +# ENV REGISTRY http://apiconnect01.rchland.ibm.com:4873/ +COPY package.json /usr/src/app/ +RUN npm config set registry $REGISTRY \ + && npm install --production + +COPY . /usr/src/app + +EXPOSE 3000 + +CMD [ "npm", "start" ] diff --git a/lib/analytics.js b/lib/analytics.js index c40ff6a..5f07f04 100644 --- a/lib/analytics.js +++ b/lib/analytics.js @@ -247,14 +247,15 @@ function performHandshake() { port: process.env[env.APIMANAGER_PORT], catalog: process.env[env.APIMANAGER_CATALOG], }; - - utils.handshakeWithAPIm(apim, function(error, result) { - if (error) { - logger.error('not able to perform the handshake with APIM, error:', error); - } else { - clientID = result.clientID; - } - }); + if (apim.host) { + utils.handshakeWithAPIm(apim, function(error, result) { + if (error) { + logger.error('not able to perform the handshake with APIM, error:', error); + } else { + clientID = result.clientID; + } + }); + } } module.exports.mkPatch = mkPatch; diff --git a/lib/api-loader/index.js b/lib/api-loader/index.js index 22ea23a..9dfb0a8 100644 --- a/lib/api-loader/index.js +++ b/lib/api-loader/index.js @@ -20,6 +20,7 @@ var optimizedDataCache = lru({ max: 3 }); //data store address var dsHost = '127.0.0.1'; var dsPort; +var odPath = '/api/optimizedData'; /* * The "api-loader" middlware reads the optimizedData from the current snapshot @@ -32,6 +33,12 @@ module.exports = function createApiLoaderMiddleware(options) { return function(req, res, next) { logger.debug('api-loader entry'); dsPort = process.env.DATASTORE_PORT; + if (process.env.DATASTORE_HOST) { + dsHost = process.env.DATASTORE_HOST; + } + if (process.env.OPTIMIZED_PATH) { + odPath = process.env.OPTIMIZED_PATH; + } async.waterfall([ //get the current snapshot id @@ -112,7 +119,7 @@ function doOptimizedDataRequest(snapshotId) { protocol: 'http', hostname: dsHost, port: dsPort, - pathname: '/api/optimizedData', + pathname: odPath, query: { filter: JSON.stringify(queryfilter) } }; var queryurl = url.format(queryurlObj); diff --git a/lib/microgw.js b/lib/microgw.js index 2f5d7b3..a550b47 100644 --- a/lib/microgw.js +++ b/lib/microgw.js @@ -55,6 +55,9 @@ exports.start = function(port) { return new Promise(function(resolve, reject) { ds.start(process.env.NODE_ENV === 'production') .then(function(useHttps) { + if (process.env.DATASTORE_HOST) { + useHttps = true; + } port = port || process.env.PORT || (useHttps ? 443 : 80); logger.debug('starting gateway ', port); if (useHttps) { diff --git a/package.json b/package.json index 21fc284..2712524 100644 --- a/package.json +++ b/package.json @@ -122,8 +122,8 @@ "loopback-component-explorer": "^2.3.0", "loopback-connector-redis": "0.0.3", "lru-cache": "^4.0.0", - "microgateway-datastore": "strongloop/microgateway-datastore", - "microgateway-util": "strongloop/microgateway-util", + "microgateway-datastore": "^1.x", + "microgateway-util": "^1.x", "moment": "^2.11.2", "multer": "^1.1.0", "osenv": "^0.1.3", From e4efd65dd72e4dc220e686e1b6ceaafc685f4a12 Mon Sep 17 00:00:00 2001 From: Jeremy R Geddes Date: Mon, 30 Jan 2017 07:52:39 -0600 Subject: [PATCH 2/3] move indention to 8 --- lib/microgw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/microgw.js b/lib/microgw.js index a550b47..5aed8c1 100644 --- a/lib/microgw.js +++ b/lib/microgw.js @@ -57,7 +57,7 @@ exports.start = function(port) { .then(function(useHttps) { if (process.env.DATASTORE_HOST) { useHttps = true; - } + } port = port || process.env.PORT || (useHttps ? 443 : 80); logger.debug('starting gateway ', port); if (useHttps) { From 25a82ac2695a0e2bcadb795e4fb2e734f071e09a Mon Sep 17 00:00:00 2001 From: Jeremy R Geddes Date: Mon, 30 Jan 2017 23:13:45 -0600 Subject: [PATCH 3/3] trigger build.. remove excess file --- abc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 abc diff --git a/abc b/abc deleted file mode 100644 index 8d1c8b6..0000000 --- a/abc +++ /dev/null @@ -1 +0,0 @@ -