From 7721a371bad07c4f5ee1f33f9efe941ff303d79c Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Tue, 21 May 2019 17:10:47 +0200 Subject: [PATCH 01/25] documentation fix --- src/oracle/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oracle/routes.js b/src/oracle/routes.js index 96d74c39..6467dc78 100644 --- a/src/oracle/routes.js +++ b/src/oracle/routes.js @@ -23,7 +23,7 @@ ******/ const Handler = require('./handler') -const tags = ['oracle', 'participants'] +const tags = ['api', 'oracle'] module.exports = [ { From 9f0c1747fcbe3b26ec3facb27c2ea337fe3c87ff Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Tue, 21 May 2019 17:14:02 +0200 Subject: [PATCH 02/25] version update --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0589b4fe..96a4b196 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.0", + "version": "6.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 00e295e6..459a0620 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.0", + "version": "6.2.1", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", From c430238b6892ed17fd7ab501a142e282bbe7ad6f Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 22 May 2019 12:38:33 +0200 Subject: [PATCH 03/25] fix for incorrect cache getting deleted --- package-lock.json | 2 +- package.json | 2 +- src/oracle/handler.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1fd4679..16252285 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.3", + "version": "6.2.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 94a9c53f..5436bb9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.3", + "version": "6.2.4", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/oracle/handler.js b/src/oracle/handler.js index b12aaf2b..62f37185 100644 --- a/src/oracle/handler.js +++ b/src/oracle/handler.js @@ -239,7 +239,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() const responseData = batchRequestCache.get(request.params.requestId) - requestsCache.del(request.params.requestId) + batchRequestCache.del(request.params.requestId) histTimerEnd({ success: true, operation: 'getRequestById' }) return h.response(responseData).code(200) } From 8bcda3b1e3b31d69f340045b795c1222730727e3 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 22 May 2019 13:28:10 +0200 Subject: [PATCH 04/25] added PUT /payeefsp/participants/{type}/{id} to the simulator so that the payeefsp can add participants --- package-lock.json | 2 +- package.json | 2 +- src/payee/handler.js | 26 ++++++++++++++++++++++++++ src/payee/routes.js | 9 +++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 16252285..788e6ef2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.4", + "version": "6.2.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5436bb9f..790d03ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.4", + "version": "6.2.5", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/payee/handler.js b/src/payee/handler.js index 12b0c738..6137e961 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -56,6 +56,32 @@ exports.metadata = function (request, h) { }).code(200) } +// Section about /participants +exports.putParticipantsByTypeId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + + Logger.info(`IN PAYEEFSP:: PUT /payeefsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + + // Saving Incoming request + let incomingRequest = { + headers: request.headers, + data: request.payload + } + callbacks.set(request.params.id, incomingRequest) + + myCache.set(request.params.id, request.payload) + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + histTimerEnd({ success: true, fsp: 'payee', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response().code(200) +} + exports.postPartiesByTypeAndId = function (request, h) { const histTimerEnd = Metrics.getHistogram( 'sim_request', diff --git a/src/payee/routes.js b/src/payee/routes.js index a9939441..616f6e67 100644 --- a/src/payee/routes.js +++ b/src/payee/routes.js @@ -33,6 +33,15 @@ module.exports = [ description: 'Metadata' } }, + { + method: 'PUT', + path: '/payeefsp/participants/{type}/{id}', + handler: Handler.putParticipantsByTypeId, + options: { + tags: tags, + description: 'Callback for adding participant' + } + }, { method: 'POST', path: '/payeefsp/parties/{type}/{id}', From 5311a32ee6215769d1007927fd9e6d2ab48fcd0a Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Mon, 27 May 2019 12:17:35 +0200 Subject: [PATCH 05/25] changed logging for all requests, health and metrics now log.debug so that logs aren't polluted on kubernetes removed accept header on GET /payeefsp/parties/{type}/{id} updated version to align with new sprint --- package-lock.json | 2 +- package.json | 2 +- src/payee/handler.js | 6 +++--- src/payee/routes.js | 1 - src/shared/plugins.js | 36 ------------------------------------ src/shared/setup.js | 9 +++++++++ 6 files changed, 14 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4aac7c74..01cdc236 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.6", + "version": "6.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b22221bd..068b6f8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "6.2.6", + "version": "6.3.0", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/payee/handler.js b/src/payee/handler.js index 06c90484..b4a61634 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -119,13 +119,13 @@ exports.getPartiesByTypeAndId = function (req, h) { } requests.set(req.params.id, incomingRequest) - const url = partiesEndpoint + '/parties/MSISDN/' + req.params.id + const url = partiesEndpoint + `/parties/${req.params.type}/${req.params.id}` try { const protectedHeader = { alg: 'RS256', 'FSPIOP-Source': `${req.headers['fspiop-destination']}`, 'FSPIOP-Destination': `${req.headers['fspiop-source']}`, - 'FSPIOP-URI': `/parties/MSISDN/${req.params.id}`, + 'FSPIOP-URI': `/parties/${req.params.type}/${req.params.id}`, 'FSPIOP-HTTP-Method': 'PUT', 'Date': '' } @@ -143,7 +143,7 @@ exports.getPartiesByTypeAndId = function (req, h) { 'Date': new Date().toUTCString(), 'FSPIOP-Signature': JSON.stringify(fspiopSignature), 'FSPIOP-HTTP-Method': 'PUT', - 'FSPIOP-URI': `/parties/MSISDN/${req.params.id}` + 'FSPIOP-URI': `/parties/${req.params.type}/${req.params.id}` }, rejectUnauthorized: false, body: JSON.stringify(myCache.get(req.params.id)) diff --git a/src/payee/routes.js b/src/payee/routes.js index be0e472c..ca5bcea0 100644 --- a/src/payee/routes.js +++ b/src/payee/routes.js @@ -71,7 +71,6 @@ module.exports = [ description: 'Add users to payer simulator', validate: { headers: Joi.object({ - 'accept': Joi.string().required().regex(/application\/vnd.interoperability[.]/), 'content-type': Joi.string().required().regex(/application\/vnd.interoperability[.]/), 'date': Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(), 'x-forwarded-for': Joi.string().optional(), diff --git a/src/shared/plugins.js b/src/shared/plugins.js index 2f1a3099..5343e4ab 100644 --- a/src/shared/plugins.js +++ b/src/shared/plugins.js @@ -26,16 +26,7 @@ const Package = require('../../package.json') const Inert = require('inert') const Vision = require('vision') const Blipp = require('blipp') -const goodWinston = require('hapi-good-winston').goodWinston const ErrorHandling = require('@mojaloop/central-services-error-handling') -const Logger = require('@mojaloop/central-services-shared').Logger - -const goodWinstonOptions = { - levels: { - response: 'debug', - error: 'error' - } -} const registerPlugins = async (server) => { await server.register({ @@ -53,36 +44,9 @@ const registerPlugins = async (server) => { options: { ops: { interval: 10000 - }, - reporters: { - // Simple and straight forward usage - winston: [goodWinston(Logger)], - // Adding some customization configuration - winstonWithLogLevels: [goodWinston(Logger, goodWinstonOptions)], - // This example simply illustrates auto loading and instantiation made by good - winston2: [ - { - module: 'hapi-good-winston', - name: 'goodWinston', - args: [Logger, goodWinstonOptions] - } - ] } } }) - - // await server.register({ - // plugin: require('hapi-auth-basic') - // }) - // - // await server.register({ - // plugin: require('@now-ims/hapi-now-auth') - // }) - // - // await server.register({ - // plugin: require('hapi-auth-bearer-token') - // }) - await server.register([Inert, Vision, Blipp, ErrorHandling]) } diff --git a/src/shared/setup.js b/src/shared/setup.js index eed2549f..5ab8eb0d 100644 --- a/src/shared/setup.js +++ b/src/shared/setup.js @@ -26,6 +26,7 @@ const Hapi = require('hapi') const Boom = require('boom') const Logger = require('@mojaloop/central-services-shared').Logger const Metrics = require('../lib/metrics') +const RequestLogger = require('../lib/requestLogger') const createServer = (port, modules) => { return (async () => { @@ -39,6 +40,14 @@ const createServer = (port, modules) => { } } }) + server.ext('onRequest', function (request, h) { + RequestLogger.logRequest(request) + return h.continue + }) + server.ext('onPreResponse', function (request, h) { + RequestLogger.logResponse(request) + return h.continue + }) Logger.info(`Registering server modules...`) await server.register(modules) From 5cdd8aa6c7d6d398ec5d02a0440cef1dc6455bcd Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Mon, 27 May 2019 12:17:53 +0200 Subject: [PATCH 06/25] no message --- src/lib/requestLogger.js | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/lib/requestLogger.js diff --git a/src/lib/requestLogger.js b/src/lib/requestLogger.js new file mode 100644 index 00000000..58ca0c1e --- /dev/null +++ b/src/lib/requestLogger.js @@ -0,0 +1,51 @@ +'use strict' + +const Logger = require('@mojaloop/central-services-shared').Logger +const Util = require('util') + +const logRequest = function (request) { + const traceId = request.headers.traceid + if (request.path.indexOf('health') > -1 || request.path.indexOf('metrics') > -1) { + Logger.debug(`L1p-Trace-Id=${traceId} - Method: ${request.method} Path: ${request.path} Query: ${JSON.stringify(request.query)}`) + Logger.debug(`L1p-Trace-Id=${traceId} - Headers: ${JSON.stringify(request.headers)}`) + if (request.body) { + Logger.debug(`L1p-Trace-Id=${traceId} - Body: ${request.body}`) + } + } else { + Logger.info(`L1p-Trace-Id=${traceId} - Method: ${request.method} Path: ${request.path} Query: ${JSON.stringify(request.query)}`) + Logger.info(`L1p-Trace-Id=${traceId} - Headers: ${JSON.stringify(request.headers)}`) + if (request.body) { + Logger.info(`L1p-Trace-Id=${traceId} - Body: ${request.body}`) + } + } +} + +const logResponse = function (request) { + const traceId = request.headers.traceid + if (request.response) { + let response + try { + response = JSON.stringify(request.response.source) + } catch (e) { + response = Util.inspect(request.response.source) + } + if (request.path.indexOf('health') > -1 || request.path.indexOf('metrics') > -1) { + if (!response) { + Logger.debug(`L1p-Trace-Id=${traceId} - Response: ${request.response}`) + } else { + Logger.debug(`L1p-Trace-Id=${traceId} - Response: ${response} Status: ${request.response.statusCode}`) + } + } else { + if (!response) { + Logger.info(`L1p-Trace-Id=${traceId} - Response: ${request.response}`) + } else { + Logger.info(`L1p-Trace-Id=${traceId} - Response: ${response} Status: ${request.response.statusCode}`) + } + } + } +} + +module.exports = { + logRequest, + logResponse +} From 57569d0b26b708ab76fbc797bf00e48c8c2c0228 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 24 Jul 2019 17:08:06 +0200 Subject: [PATCH 07/25] transactions requests handler --- src/transactionRequests/handler.js | 284 +++++++++++++++++++++++++++++ src/transactionRequests/routes.js | 83 +++++++++ 2 files changed, 367 insertions(+) create mode 100644 src/transactionRequests/handler.js create mode 100644 src/transactionRequests/routes.js diff --git a/src/transactionRequests/handler.js b/src/transactionRequests/handler.js new file mode 100644 index 00000000..62f37185 --- /dev/null +++ b/src/transactionRequests/handler.js @@ -0,0 +1,284 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + + * Rajiv Mothilal + + -------------- + ******/ + +'use strict' +const NodeCache = require('node-cache') +const participantsCache = new NodeCache() +const requestsCache = new NodeCache() +const batchRequestCache = new NodeCache() +const Logger = require('@mojaloop/central-services-shared').Logger +const Metrics = require('../lib/metrics') + +exports.createParticipantsByTypeAndId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + Logger.debug(`createParticipantByTypeId::ID=${request.params.ID} payload=${request.payload}`) + addNewRequest(request) + const record = { + partyList: [ + { + fspId: request.payload.fspId, + currency: request.payload.currency || undefined, + partySubIdOrType: request.payload.partySubIdOrType || undefined + } + ] + } + let idMap = new Map() + if (participantsCache.get(request.params.Type)) { + idMap = participantsCache.get(request.params.Type) + if (idMap.get(request.params.ID)) { + throw new Error(`ID:${request.params.ID} already exists`) + } else { + idMap.set(request.params.ID, record) + participantsCache.set(request.params.Type, idMap) + } + } else { + idMap.set(request.params.ID, record) + participantsCache.set(request.params.Type, idMap) + } + + histTimerEnd({ success: true, operation: 'postParticipants', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response().code(201) +} + +exports.getParticipantsByTypeId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + Logger.debug(`getParticipantsByTypeId::ID=${request.params.ID}`) + addNewRequest(request) + let idMap = new Map() + let response + if (participantsCache.get(request.params.Type)) { + idMap = participantsCache.get(request.params.Type) + if (idMap.get(request.params.ID)) { + response = idMap.get(request.params.ID) + } else { + response = [] + } + } else { + response = [] + } + histTimerEnd({ success: true, operation: 'getParticipants', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response(response).code(200) +} + +exports.updateParticipantsByTypeId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + Logger.debug(`updateParticipantByTypeId::ID=${request.params.ID} payload=${request.payload}`) + addNewRequest(request) + let idMap + if (participantsCache.get(request.params.Type)) { + idMap = participantsCache.get(request.params.Type) + if (idMap.get(request.params.ID)) { + const currentRecord = idMap.get(request.params.ID) + if (request.payload.fspId && currentRecord.partyList[0].fspId !== request.payload.fspId) { + currentRecord.partyList[0].fspId = request.payload.fspId + } + if (request.payload.currency && currentRecord.partyList[0].currency !== request.payload.currency) { + currentRecord.partyList[0].currency = request.payload.currency + } + if (request.payload.partySubIdOrType && currentRecord.partyList[0].partySubIdOrType !== request.payload.partySubIdOrType) { + currentRecord.partyList[0].partySubIdOrType = request.payload.partySubIdOrType + } + idMap.set(request.params.ID, currentRecord) + participantsCache.set(request.params.Type, idMap) + } else { + throw new Error(`ID:${request.params.ID} not found`) + } + } else { + throw new Error(`Type:${request.params.Type} not found`) + } + histTimerEnd({ success: true, operation: 'putParticipants', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response().code(200) +} + +exports.delParticipantsByTypeId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + Logger.debug(`delParticipantsByTypeId::ID=${request.params.ID}`) + addNewRequest(request) + let idMap + if (participantsCache.get(request.params.Type)) { + idMap = participantsCache.get(request.params.Type) + if (idMap.get(request.params.ID)) { + idMap.delete(request.params.ID) + participantsCache.set(request.params.Type, idMap) + } else { + let errorObject = { + errorCode: 2345, + errorDescription: `ID:${request.params.ID} not found` + } + histTimerEnd({ success: false, operation: 'deleteParticipants', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response(buildErrorObject(errorObject, [])).code(400) + } + } else { + throw new Error(`Type:${request.params.Type} not found`) + } + histTimerEnd({ success: true, operation: 'delParticipants', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response().code(204) +} + +exports.createParticipantsBatch = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + let responseObject = { + partyList: [] + } + if (batchRequestCache.get(request.payload.requestId)) { + let errorObject = { + errorCode: 2345, + errorDescription: `Duplicated batch requestId:${request.payload.requestId} received` + } + return h.response(buildErrorObject(errorObject, [])).code(400) + } else { + let newRequest = { + headers: request.headers, + path: request.path, + method: request.method, + params: request.params, + payload: request.payload + } + batchRequestCache.set(request.payload.requestId, newRequest) + for (let party of request.payload.partyList) { + const record = { + partyList: [ + { + fspId: party.fspId, + currency: party.currency, + partySubIdOrType: party.partySubIdOrType + } + ] + } + let partyId = { + partyIdType: party.partyIdType, + partyIdentifier: party.partyIdentifier, + partySubIdOrType: party.partySubIdOrType || undefined, + fspId: party.fspId, + currency: party.currency || undefined + } + let errorInformation + let idMap = new Map() + if (participantsCache.get(party.partyIdType)) { + idMap = participantsCache.get(party.partyIdType) + if (idMap.get(party.partyIdentifier)) { + let errorObject = { + errorCode: 1234, + errorDescription: `Participant:${party.partyIdentifier} already exists` + } + errorInformation = buildErrorObject(errorObject, [{ key: party.partyIdentifier, value: party.partyIdType }]) + responseObject.partyList.push({ partyId, errorInformation }) + } else { + idMap.set(party.partyIdentifier, record) + participantsCache.set(party.partyIdType, idMap) + responseObject.partyList.push({ partyId }) + } + } else { + idMap.set(party.partyIdentifier, record) + participantsCache.set(party.partyIdType, idMap) + responseObject.partyList.push({ partyId }) + } + } + } + histTimerEnd({ success: true, operation: 'postParticipantsBatch', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + return h.response(responseObject).code(201) +} + +exports.getRequestByTypeId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + const responseData = requestsCache.get(request.params.ID) + requestsCache.del(request.params.ID) + histTimerEnd({ success: true, operation: 'getRequestByTypeId' }) + return h.response(responseData).code(200) +} + +exports.getRequestById = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + const responseData = batchRequestCache.get(request.params.requestId) + batchRequestCache.del(request.params.requestId) + histTimerEnd({ success: true, operation: 'getRequestById' }) + return h.response(responseData).code(200) +} + +const addNewRequest = function (request) { + let newRequest = { + headers: request.headers, + path: request.path, + method: request.method, + params: request.params, + payload: request.payload ? request.payload : undefined + } + if (requestsCache.get(request.params.ID)) { + let incomingRequests = requestsCache.get(request.params.ID) + let foundMethod = false + let count = 0 + for (let entry of incomingRequests) { + if (entry.method === newRequest.method) { + foundMethod = true + break + } + count++ + } + if (!foundMethod) { + incomingRequests.push(newRequest) + } else { + incomingRequests.splice(count, 1) + incomingRequests.push(newRequest) + } + requestsCache.set(request.params.ID, incomingRequests) + } else { + requestsCache.set(request.params.ID, [newRequest]) + } +} + +const buildErrorObject = function (error, extensionList) { + return { + errorCode: error.errorCode.toString(), + errorDescription: error.errorDescription, + extensionList + } +} diff --git a/src/transactionRequests/routes.js b/src/transactionRequests/routes.js new file mode 100644 index 00000000..a91b2680 --- /dev/null +++ b/src/transactionRequests/routes.js @@ -0,0 +1,83 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + + * Rajiv Mothilal + + -------------- + ******/ + +const Handler = require('./handler') +const tags = ['api', 'transactionRequests'] + +module.exports = [ + { + method: 'GET', + path: '/transactionRequests/{ID}', + handler: Handler.getParticipantsByTypeId, + options: { + tags: tags, + description: 'Get list of participants' + } + }, + { + method: 'POST', + path: '/transactionRequests', + handler: Handler.createParticipantsByTypeAndId, + config: { + tags: tags, + description: 'Create participants' + } + }, + { + method: 'PUT', + path: '/transactionRequests/{ID}', + handler: Handler.updateParticipantsByTypeId, + options: { + tags: tags, + description: 'Update participants' + } + }, + { + method: 'PUT', + path: '/transactionRequests/{ID}/error', + handler: Handler.delParticipantsByTypeId, + options: { + tags: tags, + description: 'Delete Participants' + } + }, + { + method: 'GET', + path: '/transactionRequests/requests/{Type}/{ID}', + handler: Handler.getRequestByTypeId, + options: { + tags: tags, + description: 'Get oracle specific requests based on Type and ID' + } + }, + { + method: 'GET', + path: '/transactionRequests/requests/{requestId}', + handler: Handler.getRequestById, + options: { + tags: tags, + description: 'Get oracle specific requests based on requestId of a batch' + } + } +] From 2529efe08e8b0f1c95d3330aa0825365cfac5903 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 24 Jul 2019 20:36:11 +0200 Subject: [PATCH 08/25] Added endpoints for bulk transfers Updated dependencies Bump version Standard fixes --- package-lock.json | 923 +++-------------------------- package.json | 14 +- src/bulkTransfers/handler.js | 254 ++++++++ src/bulkTransfers/routes.js | 202 +++++++ src/shared/plugins.js | 4 +- src/shared/setup.js | 4 +- src/transactionRequests/handler.js | 20 +- 7 files changed, 574 insertions(+), 847 deletions(-) create mode 100644 src/bulkTransfers/handler.js create mode 100644 src/bulkTransfers/routes.js diff --git a/package-lock.json b/package-lock.json index b552ecb7..ea57781d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "7.1.1", + "version": "7.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -184,6 +184,26 @@ "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-6.2.4.tgz", "integrity": "sha512-HOJ20Kc93DkDVvjwHyHawPwPkX44sIrbXazAUDiUXaY2R9JwQGo2PhFfnQtdrsIe4igjG2fPgMra7NYw7qhy0A==" }, + "@hapi/inert": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/@hapi/inert/-/inert-5.2.1.tgz", + "integrity": "sha512-kovx94LVcT9jELc+k4xuR+1lsdmimjHKn9SpI/YAXDioO7m4YzksEBSmneH3ZwVWVnl2j66Sfzvs2IweHRxyNA==", + "requires": { + "@hapi/ammo": "3.x.x", + "@hapi/boom": "7.x.x", + "@hapi/bounce": "1.x.x", + "@hapi/hoek": "8.x.x", + "@hapi/joi": "15.x.x", + "lru-cache": "4.1.x" + }, + "dependencies": { + "@hapi/hoek": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", + "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==" + } + } + }, "@hapi/iron": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@hapi/iron/-/iron-5.1.0.tgz", @@ -454,19 +474,10 @@ "winston": "3.2.1" } }, - "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", - "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" - } - }, "acorn": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.0.tgz", - "integrity": "sha512-8oe72N3WPMjA+2zVG71Ia0nXZ8DpQH+QyyHO+p06jT8eg8FGG3FbcUIi8KziHlAfheJQZeoqbvq1mQSQHXKYLw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz", + "integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==", "dev": true }, "acorn-jsx": { @@ -486,21 +497,6 @@ "uri-js": "^4.2.2" } }, - "ammo": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/ammo/-/ammo-3.0.3.tgz", - "integrity": "sha512-vo76VJ44MkUBZL/BzpGXaKzMfroF4ZR6+haRuw9p+eSWfoNaH2AxVc8xmiEPC08jhzJSeM6w7/iMUGet8b4oBQ==", - "requires": { - "hoek": "6.x.x" - }, - "dependencies": { - "hoek": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", - "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==" - } - } - }, "ansi-escapes": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", @@ -520,11 +516,6 @@ "color-convert": "^1.9.0" } }, - "any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -675,22 +666,6 @@ } } }, - "bounce": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/bounce/-/bounce-1.2.3.tgz", - "integrity": "sha512-3G7B8CyBnip5EahCZJjnvQ1HLyArC6P5e+xcolo13BVI9ogFaDOsNMAE7FIWliHtIkYI8/nTRCvCY9tZa3Mu4g==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x" - }, - "dependencies": { - "hoek": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", - "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==" - } - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -711,20 +686,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" - }, - "cache-content-type": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-content-type/-/cache-content-type-1.0.1.tgz", - "integrity": "sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==", - "requires": { - "mime-types": "^2.1.18", - "ylru": "^1.2.0" - } - }, "call-me-maybe": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", @@ -784,22 +745,6 @@ "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "optional": true }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, - "co-body": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/co-body/-/co-body-6.0.0.tgz", - "integrity": "sha512-9ZIcixguuuKIptnY8yemEOuhb71L/lLf+Rl5JfJEUiDNJk0e02MBt7BPxR2GEh5mw8dPthQYR4jPI/BnS1MQgw==", - "requires": { - "inflation": "^2.0.0", - "qs": "^6.5.2", - "raw-body": "^2.3.3", - "type-is": "^1.6.16" - } - }, "color": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", @@ -913,33 +858,6 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, - "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", - "requires": { - "safe-buffer": "5.1.2" - } - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" - }, - "cookies": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/cookies/-/cookies-0.7.3.tgz", - "integrity": "sha512-+gixgxYSgQLTaTIilDHAdlNPZDENDQernEMiIcZpYYP14zgHsCt4Ce1FEjFtcp6GefhozebB6orvhAAWx/IS0A==", - "requires": { - "depd": "~1.1.2", - "keygrip": "~1.0.3" - } - }, - "copy-to": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/copy-to/-/copy-to-2.0.1.tgz", - "integrity": "sha1-JoD7uAaKSNCGVrYJgJK9r8kG9KU=" - }, "core-js": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz", @@ -984,11 +902,6 @@ "integrity": "sha1-IwdjLUwEOCuN+KMvcLiVBG1SdF8=", "dev": true }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=" - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -1045,21 +958,6 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" - }, "diagnostics": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", @@ -1158,11 +1056,6 @@ "nan": "^2.0.9" } }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" - }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -1213,11 +1106,6 @@ } } }, - "error-inject": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/error-inject/-/error-inject-1.0.0.tgz", - "integrity": "sha1-4rPZG1Su1nLzCdlQ0VSFD6EdTzc=" - }, "es-abstract": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", @@ -1241,20 +1129,15 @@ "is-symbol": "^1.0.2" } }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "eslint": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.0.1.tgz", - "integrity": "sha512-DyQRaMmORQ+JsWShYsSg4OPTjY56u1nCjAmICrE8vLWqyLKxhFXOthwMj1SA8xwfrv0CofLNVnqbfyhwCkaO0w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.1.0.tgz", + "integrity": "sha512-QhrbdRD7ofuV09IuE2ySWBz0FyXCq0rriLTZXZqaWSI79CVtHVRdkFuFTViiqzZhkCgfOh9USpriuGN2gIpZDQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -1263,7 +1146,7 @@ "cross-spawn": "^6.0.5", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", + "eslint-scope": "^5.0.0", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", "espree": "^6.0.0", @@ -1271,28 +1154,29 @@ "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob-parent": "^3.1.0", + "glob-parent": "^5.0.0", "globals": "^11.7.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", + "inquirer": "^6.4.1", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.11", + "lodash": "^4.17.14", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", "progress": "^2.0.0", "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", "table": "^5.2.3", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "dependencies": { "ajv": { @@ -1306,6 +1190,12 @@ "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true } } }, @@ -1349,9 +1239,9 @@ } }, "eslint-module-utils": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.0.tgz", - "integrity": "sha512-14tltLm38Eu3zS+mt0KvILC3q8jyIAH518MlG+HO0p+yK885Lb1UHTY/UgR91eOyGdmxAPb+OLoW4znqIT6Ndw==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz", + "integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==", "dev": true, "requires": { "debug": "^2.6.8", @@ -1386,9 +1276,9 @@ } }, "eslint-plugin-import": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.0.tgz", - "integrity": "sha512-PZpAEC4gj/6DEMMoU2Df01C5c50r7zdGIN52Yfi7CvvWaYssG7Jt5R9nFG5gmqodxNOz9vQS87xk6Izdtpdrig==", + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz", + "integrity": "sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -1398,8 +1288,8 @@ "eslint-import-resolver-node": "^0.3.2", "eslint-module-utils": "^2.4.0", "has": "^1.0.3", - "lodash": "^4.17.11", "minimatch": "^3.0.4", + "object.values": "^1.1.0", "read-pkg-up": "^2.0.0", "resolve": "^1.11.0" }, @@ -1470,9 +1360,9 @@ } }, "semver": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", - "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true } } @@ -1484,9 +1374,9 @@ "dev": true }, "eslint-plugin-react": { - "version": "7.14.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.14.2.tgz", - "integrity": "sha512-jZdnKe3ip7FQOdjxks9XPN0pjUKZYq48OggNMd16Sk+8VXx6JOvXmlElxROCgp7tiUsTsze3jd78s/9AFJP2mA==", + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.14.3.tgz", + "integrity": "sha512-EzdyyBWC4Uz2hPYBiEJrKCUi2Fn+BJ9B/pJQcjw5X+x/H2Nm59S4MJIvL4O5NEE0+WbnQwEBxWY03oUk+Bc3FA==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -1527,9 +1417,9 @@ "dev": true }, "eslint-scope": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", - "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", "dev": true, "requires": { "esrecurse": "^4.1.0", @@ -1746,11 +1636,6 @@ "resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.3.tgz", "integrity": "sha1-Ay3KShFiYqEsQ/TD7IVmQWxbLZU=" }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1795,24 +1680,12 @@ } }, "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", + "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", "dev": true, "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } + "is-glob": "^4.0.1" } }, "globals": { @@ -1821,34 +1694,6 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, - "good": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/good/-/good-8.1.2.tgz", - "integrity": "sha512-yQ/OE+b8pY+Uc79zrv7PpzWSORI+scyeItIgkOx6PhYKkdnwhtXPGCOhZVv5rbcuVrLeh73HcjkwcOQbYMTJkw==", - "requires": { - "hoek": "6.x.x", - "joi": "14.x.x", - "oppsy": "2.x.x", - "pumpify": "1.3.x" - }, - "dependencies": { - "hoek": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.2.tgz", - "integrity": "sha512-6qhh/wahGYZHFSFw12tBbJw5fsAhhwrrG/y3Cs0YMTv2WzMnL0oLPnQJjv1QJvEfylRSOFuP+xCu+tdx0tD16Q==" - }, - "joi": { - "version": "14.3.1", - "resolved": "https://registry.npmjs.org/joi/-/joi-14.3.1.tgz", - "integrity": "sha512-LQDdM+pkOrpAn4Lp+neNIFV3axv1Vna3j38bisbQhETPMANYRbFJFUyOZcOClYvM/hppMhGWuKSFEK9vjrB+bQ==", - "requires": { - "hoek": "6.x.x", - "isemail": "3.x.x", - "topo": "3.x.x" - } - } - } - }, "graceful-fs": { "version": "4.1.15", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", @@ -1865,279 +1710,6 @@ "uglify-js": "^3.1.4" } }, - "hapi": { - "version": "18.1.0", - "resolved": "https://registry.npmjs.org/hapi/-/hapi-18.1.0.tgz", - "integrity": "sha512-nSU1VLyTAgp7P5gy47QzJIP2JAb+wOFvJIV3gnL0lFj/mD+HuTXhyUsDYXjF/dhADMVXVEz31z6SUHBJhtsvGA==", - "requires": { - "accept": "3.x.x", - "ammo": "3.x.x", - "boom": "7.x.x", - "bounce": "1.x.x", - "call": "5.x.x", - "catbox": "10.x.x", - "catbox-memory": "4.x.x", - "heavy": "6.x.x", - "hoek": "6.x.x", - "joi": "14.x.x", - "mimos": "4.x.x", - "podium": "3.x.x", - "shot": "4.x.x", - "somever": "2.x.x", - "statehood": "6.x.x", - "subtext": "6.x.x", - "teamwork": "3.x.x", - "topo": "3.x.x" - }, - "dependencies": { - "accept": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/accept/-/accept-3.1.3.tgz", - "integrity": "sha512-OgOEAidVEOKPup+Gv2+2wdH2AgVKI9LxsJ4hicdJ6cY0faUuZdZoi56kkXWlHp9qicN1nWQLmW5ZRGk+SBS5xg==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x" - } - }, - "ammo": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/ammo/-/ammo-3.0.3.tgz", - "integrity": "sha512-vo76VJ44MkUBZL/BzpGXaKzMfroF4ZR6+haRuw9p+eSWfoNaH2AxVc8xmiEPC08jhzJSeM6w7/iMUGet8b4oBQ==", - "requires": { - "hoek": "6.x.x" - } - }, - "b64": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/b64/-/b64-4.1.2.tgz", - "integrity": "sha512-+GUspBxlH3CJaxMUGUE1EBoWM6RKgWiYwUDal0qdf8m3ArnXNN1KzKVo5HOnE/FSq4HHyWf3TlHLsZI8PKQgrQ==", - "requires": { - "hoek": "6.x.x" - } - }, - "boom": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", - "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", - "requires": { - "hoek": "6.x.x" - } - }, - "bounce": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/bounce/-/bounce-1.2.3.tgz", - "integrity": "sha512-3G7B8CyBnip5EahCZJjnvQ1HLyArC6P5e+xcolo13BVI9ogFaDOsNMAE7FIWliHtIkYI8/nTRCvCY9tZa3Mu4g==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x" - } - }, - "bourne": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bourne/-/bourne-1.1.1.tgz", - "integrity": "sha512-Ou0l3W8+n1FuTOoIfIrCk9oF9WVWc+9fKoAl67XQr9Ws0z7LgILRZ7qtc9xdT4BveSKtnYXfKPgn8pFAqeQRew==" - }, - "call": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/call/-/call-5.0.3.tgz", - "integrity": "sha512-eX16KHiAYXugbFu6VifstSdwH6aMuWWb4s0qvpq1nR1b+Sf+u68jjttg8ixDBEldPqBi30bDU35OJQWKeTLKxg==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x" - } - }, - "catbox": { - "version": "10.0.6", - "resolved": "https://registry.npmjs.org/catbox/-/catbox-10.0.6.tgz", - "integrity": "sha512-gQWCnF/jbHcfwGbQ4FQxyRiAwLRipqWTTXjpq7rTqqdcsnZosFa0L3LsCZcPTF33QIeMMkS7QmFBHt6QdzGPvg==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x", - "joi": "14.x.x" - } - }, - "catbox-memory": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/catbox-memory/-/catbox-memory-4.0.1.tgz", - "integrity": "sha512-ZmqNiLsYCIu9qvBJ/MQbznDV2bFH5gFiH67TgIJgSSffJFtTXArT+MM3AvJQlby9NSkLHOX4eH/uuUqnch/Ldw==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x" - } - }, - "content": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/content/-/content-4.0.6.tgz", - "integrity": "sha512-lR9ND3dXiMdmsE84K6l02rMdgiBVmtYWu1Vr/gfSGHcIcznBj2QxmSdUgDuNFOA+G9yrb1IIWkZ7aKtB6hDGyA==", - "requires": { - "boom": "7.x.x" - } - }, - "cryptiles": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-4.1.3.tgz", - "integrity": "sha512-gT9nyTMSUC1JnziQpPbxKGBbUg8VL7Zn2NB4E1cJYvuXdElHrwxrV9bmltZGDzet45zSDGyYceueke1TjynGzw==", - "requires": { - "boom": "7.x.x" - } - }, - "heavy": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/heavy/-/heavy-6.1.2.tgz", - "integrity": "sha512-cJp884bqhiebNcEHydW0g6V1MUGYOXRPw9c7MFiHQnuGxtbWuSZpsbojwb2kxb3AA1/Rfs8CNiV9MMOF8pFRDg==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x", - "joi": "14.x.x" - } - }, - "hoek": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.2.tgz", - "integrity": "sha512-6qhh/wahGYZHFSFw12tBbJw5fsAhhwrrG/y3Cs0YMTv2WzMnL0oLPnQJjv1QJvEfylRSOFuP+xCu+tdx0tD16Q==" - }, - "iron": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/iron/-/iron-5.0.6.tgz", - "integrity": "sha512-zYUMOSkEXGBdwlV/AXF9zJC0aLuTJUKHkGeYS5I2g225M5i6SrxQyGJGhPgOR8BK1omL6N5i6TcwfsXbP8/Exw==", - "requires": { - "b64": "4.x.x", - "boom": "7.x.x", - "cryptiles": "4.x.x", - "hoek": "6.x.x" - } - }, - "joi": { - "version": "14.3.1", - "resolved": "https://registry.npmjs.org/joi/-/joi-14.3.1.tgz", - "integrity": "sha512-LQDdM+pkOrpAn4Lp+neNIFV3axv1Vna3j38bisbQhETPMANYRbFJFUyOZcOClYvM/hppMhGWuKSFEK9vjrB+bQ==", - "requires": { - "hoek": "6.x.x", - "isemail": "3.x.x", - "topo": "3.x.x" - } - }, - "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" - }, - "mimos": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/mimos/-/mimos-4.0.2.tgz", - "integrity": "sha512-5XBsDqBqzSN88XPPH/TFpOalWOjHJM5Z2d3AMx/30iq+qXvYKd/8MPhqBwZDOLtoaIWInR3nLzMQcxfGK9djXA==", - "requires": { - "hoek": "6.x.x", - "mime-db": "1.x.x" - } - }, - "nigel": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/nigel/-/nigel-3.0.4.tgz", - "integrity": "sha512-3SZCCS/duVDGxFpTROHEieC+itDo4UqL9JNUyQJv3rljudQbK6aqus5B4470OxhESPJLN93Qqxg16rH7DUjbfQ==", - "requires": { - "hoek": "6.x.x", - "vise": "3.x.x" - } - }, - "pez": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pez/-/pez-4.0.5.tgz", - "integrity": "sha512-HvL8uiFIlkXbx/qw4B8jKDCWzo7Pnnd65Uvanf9OOCtb20MRcb9gtTVBf9NCnhETif1/nzbDHIjAWC/sUp7LIQ==", - "requires": { - "b64": "4.x.x", - "boom": "7.x.x", - "content": "4.x.x", - "hoek": "6.x.x", - "nigel": "3.x.x" - } - }, - "podium": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/podium/-/podium-3.2.0.tgz", - "integrity": "sha512-rbwvxwVkI6gRRlxZQ1zUeafrpGxZ7QPHIheinehAvGATvGIPfWRkaTeWedc5P4YjXJXEV8ZbBxPtglNylF9hjw==", - "requires": { - "hoek": "6.x.x", - "joi": "14.x.x" - } - }, - "shot": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/shot/-/shot-4.0.7.tgz", - "integrity": "sha512-RKaKAGKxJ11EjJl0cf2fYVSsd4KB5Cncb9J0v7w+0iIaXpxNqFWTYNDNhBX7f0XSyDrjOH9a4OWZ9Gp/ZML+ew==", - "requires": { - "hoek": "6.x.x", - "joi": "14.x.x" - } - }, - "somever": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/somever/-/somever-2.0.0.tgz", - "integrity": "sha512-9JaIPP+HxwYGqCDqqK3tRaTqdtQHoK6Qy3IrXhIt2q5x8fs8RcfU7BMWlFTCOgFazK8p88zIv1tHQXvAwtXMyw==", - "requires": { - "bounce": "1.x.x", - "hoek": "6.x.x" - } - }, - "statehood": { - "version": "6.0.9", - "resolved": "https://registry.npmjs.org/statehood/-/statehood-6.0.9.tgz", - "integrity": "sha512-jbFg1+MYEqfC7ABAoWZoeF4cQUtp3LUvMDUGExL76cMmleBHG7I6xlZFsE8hRi7nEySIvutHmVlLmBe9+2R5LQ==", - "requires": { - "boom": "7.x.x", - "bounce": "1.x.x", - "bourne": "1.x.x", - "cryptiles": "4.x.x", - "hoek": "6.x.x", - "iron": "5.x.x", - "joi": "14.x.x" - } - }, - "subtext": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/subtext/-/subtext-6.0.12.tgz", - "integrity": "sha512-yT1wCDWVgqvL9BIkWzWqgj5spUSYo/Enu09iUV8t2ZvHcr2tKGTGg2kc9tUpVEsdhp1ihsZeTAiDqh0TQciTPQ==", - "requires": { - "boom": "7.x.x", - "bourne": "1.x.x", - "content": "4.x.x", - "hoek": "6.x.x", - "pez": "4.x.x", - "wreck": "14.x.x" - } - }, - "teamwork": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/teamwork/-/teamwork-3.0.3.tgz", - "integrity": "sha512-OCB56z+G70iA1A1OFoT+51TPzfcgN0ks75uN3yhxA+EU66WTz2BevNDK4YzMqfaL5tuAvxy4iFUn35/u8pxMaQ==" - }, - "topo": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/topo/-/topo-3.0.3.tgz", - "integrity": "sha512-IgpPtvD4kjrJ7CRA3ov2FhWQADwv+Tdqbsf1ZnPUSAtCJ9e1Z44MmoSGDXGk4IppoZA7jd/QRkNddlLJWlUZsQ==", - "requires": { - "hoek": "6.x.x" - } - }, - "vise": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/vise/-/vise-3.0.2.tgz", - "integrity": "sha512-X52VtdRQbSBXdjcazRiY3eRgV3vTQ0B+7Wh8uC9cVv7lKfML5m9+9NHlbcgCY0R9EAqD1v/v7o9mhGh2A3ANFg==", - "requires": { - "hoek": "6.x.x" - } - }, - "wreck": { - "version": "14.1.3", - "resolved": "https://registry.npmjs.org/wreck/-/wreck-14.1.3.tgz", - "integrity": "sha512-hb/BUtjX3ObbwO3slCOLCenQ4EP8e+n8j6FmTne3VhEFp5XV1faSJojiyxVSvw34vgdeTG5baLTl4NmjwokLlw==", - "requires": { - "boom": "7.x.x", - "hoek": "6.x.x" - } - } - } - }, "hapi-good-winston": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/hapi-good-winston/-/hapi-good-winston-3.0.0.tgz", @@ -2267,27 +1839,6 @@ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" }, - "http-assert": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/http-assert/-/http-assert-1.4.0.tgz", - "integrity": "sha512-tPVv62a6l3BbQoM/N5qo969l0OFxqpnQzNUPeYfTP6Spo4zkgWeDBD1D5thI7sDLg7jCCihXTLB0X8UtdyAy8A==", - "requires": { - "deep-equal": "~1.0.1", - "http-errors": "~1.7.1" - } - }, - "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - } - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -2303,14 +1854,6 @@ "resolved": "https://registry.npmjs.org/http-status/-/http-status-1.3.2.tgz", "integrity": "sha512-vR1YTaDyi2BukI0UiH01xy92oiZi4in7r0dmSPnrZg72Vu1SzyOLalwWP5NUk1rNiB2L+XVK2lcSVOqaertX8A==" }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -2343,41 +1886,6 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, - "inert": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/inert/-/inert-5.1.3.tgz", - "integrity": "sha512-xLtqTOcJe+/RBaXkH0ZFai91SFj1a27ZXjFLLyiezLGhZCkBvMA+YGe6hNVVA678mb4EudKW35q1hATkxfUvMA==", - "requires": { - "ammo": "3.x.x", - "boom": "7.x.x", - "bounce": "1.x.x", - "hoek": "6.x.x", - "joi": "14.x.x", - "lru-cache": "4.1.x" - }, - "dependencies": { - "hoek": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", - "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==" - }, - "joi": { - "version": "14.3.1", - "resolved": "https://registry.npmjs.org/joi/-/joi-14.3.1.tgz", - "integrity": "sha512-LQDdM+pkOrpAn4Lp+neNIFV3axv1Vna3j38bisbQhETPMANYRbFJFUyOZcOClYvM/hppMhGWuKSFEK9vjrB+bQ==", - "requires": { - "hoek": "6.x.x", - "isemail": "3.x.x", - "topo": "3.x.x" - } - } - } - }, - "inflation": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.0.0.tgz", - "integrity": "sha1-i0F+R8KPklpFEz2RTKH9OJEH8w8=" - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2411,29 +1919,6 @@ "string-width": "^2.1.0", "strip-ansi": "^5.1.0", "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } } }, "is-arrayish": { @@ -2468,11 +1953,6 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, - "is-generator-function": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.7.tgz", - "integrity": "sha512-YZc5EwyO4f2kWCax7oegfuSr9mFz1ZvieNYBEjmukLxgXfBUbxAWGVF7GZf0zidYtoBl3WvC07YK0wT76a+Rtw==" - }, "is-glob": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", @@ -2700,95 +2180,6 @@ "safe-buffer": "^5.0.1" } }, - "keygrip": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.0.3.tgz", - "integrity": "sha512-/PpesirAIfaklxUzp4Yb7xBper9MwP6hNRA6BGGUFCgbJ+BM5CKBtsoxinNXkLHAr+GXS1/lSlF2rP7cv5Fl+g==" - }, - "koa": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/koa/-/koa-2.7.0.tgz", - "integrity": "sha512-7ojD05s2Q+hFudF8tDLZ1CpCdVZw8JQELWSkcfG9bdtoTDzMmkRF6BQBU7JzIzCCOY3xd3tftiy/loHBUYaY2Q==", - "requires": { - "accepts": "^1.3.5", - "cache-content-type": "^1.0.0", - "content-disposition": "~0.5.2", - "content-type": "^1.0.4", - "cookies": "~0.7.1", - "debug": "~3.1.0", - "delegates": "^1.0.0", - "depd": "^1.1.2", - "destroy": "^1.0.4", - "error-inject": "^1.0.0", - "escape-html": "^1.0.3", - "fresh": "~0.5.2", - "http-assert": "^1.3.0", - "http-errors": "^1.6.3", - "is-generator-function": "^1.0.7", - "koa-compose": "^4.1.0", - "koa-convert": "^1.2.0", - "koa-is-json": "^1.0.0", - "on-finished": "^2.3.0", - "only": "~0.0.2", - "parseurl": "^1.3.2", - "statuses": "^1.5.0", - "type-is": "^1.6.16", - "vary": "^1.1.2" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, - "koa-bodyparser": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/koa-bodyparser/-/koa-bodyparser-4.2.1.tgz", - "integrity": "sha512-UIjPAlMZfNYDDe+4zBaOAUKYqkwAGcIU6r2ARf1UOXPAlfennQys5IiShaVeNf7KkVBlf88f2LeLvBFvKylttw==", - "requires": { - "co-body": "^6.0.0", - "copy-to": "^2.0.1" - } - }, - "koa-compose": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.1.0.tgz", - "integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==" - }, - "koa-convert": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-1.2.0.tgz", - "integrity": "sha1-2kCHXfSd4FOQmNFwC1CCDOvNIdA=", - "requires": { - "co": "^4.6.0", - "koa-compose": "^3.0.0" - }, - "dependencies": { - "koa-compose": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-3.2.1.tgz", - "integrity": "sha1-qFzLQLfZhtjlo0Wzoazo6rz1Tec=", - "requires": { - "any-promise": "^1.1.0" - } - } - } - }, - "koa-is-json": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/koa-is-json/-/koa-is-json-1.0.0.tgz", - "integrity": "sha1-JzwH7c3Ljfaiwat9We52SRRR7BQ=" - }, "kuler": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", @@ -2913,11 +2304,6 @@ "yallist": "^2.1.2" } }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, "memorystream": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", @@ -3019,11 +2405,6 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" - }, "neo-async": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", @@ -3177,14 +2558,6 @@ "bignumber.js": "^7.2.1" } }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "requires": { - "ee-first": "1.1.1" - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -3207,11 +2580,6 @@ "mimic-fn": "^1.0.0" } }, - "only": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", - "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=" - }, "ono": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/ono/-/ono-4.0.11.tgz", @@ -3220,21 +2588,6 @@ "format-util": "^1.0.3" } }, - "oppsy": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/oppsy/-/oppsy-2.0.1.tgz", - "integrity": "sha512-6cIrRlZiQE4q+PadDP08N6RLQgQr2KmAbDvRFET3aL5A4bZnecNmSxa9ENe+TAE29XRX+KgaxaqC+B2+Lc51Yw==", - "requires": { - "hoek": "6.x.x" - }, - "dependencies": { - "hoek": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.2.tgz", - "integrity": "sha512-6qhh/wahGYZHFSFw12tBbJw5fsAhhwrrG/y3Cs0YMTv2WzMnL0oLPnQJjv1QJvEfylRSOFuP+xCu+tdx0tD16Q==" - } - } - }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -3320,17 +2673,6 @@ "json-parse-better-errors": "^1.0.1" } }, - "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -3572,40 +2914,6 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, - "qs": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.6.0.tgz", - "integrity": "sha512-KIJqT9jQJDQx5h5uAVPimw6yVg2SekOKu959OCtktD3FjzbpvaPr8i4zzg07DOMz+igA4W/aNM7OV8H37pFYfA==" - }, - "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", - "unpipe": "1.0.0" - }, - "dependencies": { - "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" - } - }, - "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" - } - } - }, "react-is": { "version": "16.8.6", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.6.tgz", @@ -3830,11 +3138,6 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" }, - "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" - }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -3965,12 +3268,12 @@ "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" }, "standard": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/standard/-/standard-13.0.2.tgz", - "integrity": "sha512-tcdJc7Oa+ZFpIcYqNaV3kG3Ikqk1Ir5dCn8vaiLWvDcXdRGvQVQGbTqW/3y4RPEHXGBXoZZRQbb6VbSGx+0aqg==", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/standard/-/standard-13.1.0.tgz", + "integrity": "sha512-h3NaMzsa88+/xtjXCMvdn6EWWdlodsI/HvtsQF+EGwrF9kVNwNha9TkFABU6bSBoNfC79YDyIAq9ekxOMBFkuw==", "dev": true, "requires": { - "eslint": "~6.0.1", + "eslint": "~6.1.0", "eslint-config-standard": "13.0.1", "eslint-config-standard-jsx": "7.0.0", "eslint-plugin-import": "~2.18.0", @@ -4001,11 +3304,6 @@ } } }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" - }, "stealthy-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", @@ -4024,6 +3322,17 @@ "requires": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, "string.prototype.padend": { @@ -4045,12 +3354,20 @@ } }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } } }, "strip-bom": { @@ -4059,9 +3376,9 @@ "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" }, "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", "dev": true }, "supports-color": { @@ -4135,18 +3452,6 @@ "uri-js": "^4.2.2" } }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -4157,15 +3462,6 @@ "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^5.1.0" } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } } } }, @@ -4203,11 +3499,6 @@ "os-tmpdir": "~1.0.2" } }, - "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" - }, "topo": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/topo/-/topo-3.0.3.tgz", @@ -4278,15 +3569,6 @@ "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", "dev": true }, - "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.18" - } - }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -4309,11 +3591,6 @@ "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", "dev": true }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -4332,6 +3609,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, + "v8-compile-cache": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz", + "integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==", + "dev": true + }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -4346,11 +3629,6 @@ "resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz", "integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==" }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" - }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -4509,11 +3787,6 @@ "camelcase": "^4.1.0" } }, - "ylru": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.2.1.tgz", - "integrity": "sha512-faQrqNMzcPCHGVC2aaOINk13K+aaBDUPjGWl0teOXywElLjyVAB6Oe2jj62jHYtwsU49jXhScYbvPENK+6zAvQ==" - }, "z-schema": { "version": "3.25.1", "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.25.1.tgz", diff --git a/package.json b/package.json index 2c379546..587a4383 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "7.1.1", + "version": "7.2.0", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", @@ -28,24 +28,22 @@ "dependencies": { "@hapi/joi": "15.1.0", "@hapi/joi-date": "1.3.0", + "@hapi/boom": "7.4.2", "@mojaloop/central-services-error-handling": "7.1.2", "@mojaloop/central-services-metrics": "5.2.0", "@mojaloop/central-services-shared": "6.4.1", "base64url": "3.0.1", "blipp": "4.0.0", - "boom": "7.3.0", "five-bells-condition": "5.0.1", "glob": "7.1.4", - "good": "8.1.2", - "hapi": "18.1.0", + "@hapi/good": "8.2.0", + "@hapi/hapi": "18.3.1", "hapi-good-winston": "3.0.0", "hapi-openapi": "1.2.2", "hapi-swagger": "10.0.2", "ilp-packet": "3.0.8", - "inert": "5.1.3", + "@hapi/inert": "5.2.1", "joi-currency-code": "2.0.2", - "koa": "2.7.0", - "koa-bodyparser": "4.2.1", "node-cache": "4.2.0", "node-fetch": "2.6.0", "npm-run-all": "4.1.5", @@ -54,7 +52,7 @@ }, "devDependencies": { "pre-commit": "1.2.2", - "standard": "13.0.2", + "standard": "13.1.0", "npm-audit-resolver": "1.5.0" } } diff --git a/src/bulkTransfers/handler.js b/src/bulkTransfers/handler.js new file mode 100644 index 00000000..d94ea63a --- /dev/null +++ b/src/bulkTransfers/handler.js @@ -0,0 +1,254 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + - Murthy Kakarlamudi murthy@modusbox.com + -------------- + ******/ + +'use strict' +const NodeCache = require('node-cache') +const myCache = new NodeCache() +const requests = new NodeCache() +const callbacks = new NodeCache() +const fetch = require('node-fetch') +const Logger = require('@mojaloop/central-services-shared').Logger +const Metrics = require('../lib/metrics') +const base64url = require('base64url') + +const transfersEndpoint = process.env.TRANSFERS_ENDPOINT || 'http://localhost:1080' +const transfersFulfilResponseDisabled = (process.env.TRANSFERS_FULFIL_RESPONSE_DISABLED !== undefined && process.env.TRANSFERS_FULFIL_RESPONSE_DISABLED !== 'false') +const transfersFulfilment = process.env.TRANSFERS_FULFILMENT || 'XoSz1cL0tljJSCp_VtIYmPNw-zFUgGfbUqf69AagUzY' +const signature = process.env.MOCK_JWS_SIGNATURE || 'abcJjvNrkyK2KBieDUbGfhaBUn75aDUATNF4joqA8OLs4QgSD7i6EO8BIdy6Crph3LnXnTM20Ai1Z6nt0zliS_qPPLU9_vi6qLb15FOkl64DQs9hnfoGeo2tcjZJ88gm19uLY_s27AJqC1GH1B8E2emLrwQMDMikwQcYvXoyLrL7LL3CjaLMKdzR7KTcQi1tCK4sNg0noIQLpV3eA61kess' + +exports.postBulkTransfers = async function (req, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + + Logger.debug(`[cid=${req.payload.bulkTransferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + + const metadata = `${req.method} ${req.path} ${req.payload.bulkTransferId}` + Logger.info(`IN Bulk Transfers POST:: received: ${metadata}.`) + + if (!transfersFulfilResponseDisabled) { + // Saving Incoming request + const incomingRequest = { + headers: req.headers, + data: req.payload + } + requests.set(req.payload.bulkTransferId, incomingRequest) + + const url = transfersEndpoint + '/bulkTransfers/' + req.payload.bulkTransferId + const fspiopUriHeader = `/bulkTransfers/${req.payload.bulkTransferId}` + try { + const listOfIndividualTransfers = [] + for (const transfer of req.payload.individualTransfers) { + const individualTransfer = { + transferId: transfer.transferId, + fulfilment: transfersFulfilment + } + listOfIndividualTransfers.push(individualTransfer) + } + const bulkTransferResponse = { + completedTimestamp: new Date().toISOString(), + individualTransferResults: listOfIndividualTransfers, + bulkTransferState: 'COMPLETED' + } + + const protectedHeader = { + alg: 'RS256', + 'FSPIOP-Source': `${req.headers['fspiop-destination']}`, + 'FSPIOP-Destination': `${req.headers['fspiop-source']}`, + 'FSPIOP-URI': `/bulkTransfers/${req.payload.transferId}`, + 'FSPIOP-HTTP-Method': 'PUT', + Date: '' + } + const fspiopSignature = { + signature: signature, + protectedHeader: `${base64url.encode(JSON.stringify(protectedHeader))}` + } + const opts = { + method: 'PUT', + headers: { + 'Content-Type': 'application/vnd.interoperability.transfers+json;version=1.0', + 'FSPIOP-Source': req.headers['fspiop-destination'], + 'FSPIOP-Destination': req.headers['fspiop-source'], + Date: new Date().toUTCString(), + 'FSPIOP-Signature': JSON.stringify(fspiopSignature), + 'FSPIOP-HTTP-Method': 'PUT', + 'FSPIOP-URI': fspiopUriHeader + }, + rejectUnauthorized: false, + body: JSON.stringify(bulkTransferResponse) + } + Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(bulkTransferResponse)}]`) + const res = await fetch(url, opts) + Logger.info(`response: ${res.status}`) + if (!res.ok) { + // TODO: how does one identify the failed response? + throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) + } + // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + histTimerEnd({ + success: true, + fsp: req.headers['fspiop-source'], + operation: 'postBulkTransfers', + source: req.headers['fspiop-source'], + destination: req.headers['fspiop-destination'] + }) + } catch (err) { + Logger.error(err) + // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + histTimerEnd({ + success: false, + fsp: req.headers['fspiop-source'], + operation: 'postBulkTransfers', + source: req.headers['fspiop-source'], + destination: req.headers['fspiop-destination'] + }) + // TODO: what if this fails? We need to log. What happens by default? + // const url = await rq.createErrorUrl(db, req.path, requesterName); + // TODO: review this error message + // TODO: we should be able to throw an AppError somewhere, test whether the error + // received in this handler is an AppError, then send the requester the correct + // payload etc. based on the contents of that AppError. + // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); + } + } else { + // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + histTimerEnd({ + success: true, + fsp: req.headers['fspiop-source'], + operation: 'postBulkTransfers', + source: req.headers['fspiop-source'], + destination: req.headers['fspiop-destination'] + }) + } + + return h.response().code(202) +} + +exports.putBulkTransfersById = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - START`) + + Logger.info(`IN Bulk Transfer:: PUT /bulkTransfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + + myCache.set(request.params.id, request.payload) + + // Saving Incoming request + const incomingRequest = { + headers: request.headers, + data: request.payload + } + callbacks.set(request.params.id, incomingRequest) + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - END`) + histTimerEnd({ + success: true, + fsp: request.headers['fspiop-source'], + operation: 'putBulkTransfersById', + source: request.headers['fspiop-source'], + destination: request.headers['fspiop-destination'] + }) + return h.response().code(200) +} + +exports.putBulkTransfersByIdError = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - START`) + + Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + myCache.set(request.params.id, request.payload) + + // Saving Incoming request + const incomingRequest = { + headers: request.headers, + data: request.payload + } + callbacks.set(request.params.id, incomingRequest) + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - END`) + histTimerEnd({ + success: true, + fsp: request.headers['fspiop-source'], + operation: 'putBulkTransfersByIdError', + source: request.headers['fspiop-source'], + destination: request.headers['fspiop-destination'] + }) + return h.response().code(200) +} + +exports.getCorrelationId = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - START`) + + Logger.info(`IN bulk transfers:: Final response for GET /bulkTransfers/correlationid/${request.params.id}, CACHE: [${JSON.stringify(myCache.get(request.params.id))}`) + + // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - END`) + histTimerEnd({ success: true, fsp: 'payee', operation: 'getBulkCorrelationId' }) + return h.response(myCache.get(request.params.id)).code(202) +} + +exports.getRequestById = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + + Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/requests/${request.params.id}, CACHE: [${JSON.stringify(requests.get(request.params.id))}]`) + const responseData = requests.get(request.params.id) + requests.del(request.params.id) + + histTimerEnd({ success: true, fsp: 'payee', operation: 'getBulkRequestById' }) + + return h.response(responseData).code(200) +} + +exports.getCallbackById = function (request, h) { + const histTimerEnd = Metrics.getHistogram( + 'sim_request', + 'Histogram for Simulator http operations', + ['success', 'fsp', 'operation', 'source', 'destination'] + ).startTimer() + + Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbacks.get(request.params.id))}]`) + const responseData = callbacks.get(request.params.id) + callbacks.del(request.params.id) + + histTimerEnd({ success: true, fsp: 'payee', operation: 'getBulkCallbackById' }) + + return h.response(responseData).code(200) +} diff --git a/src/bulkTransfers/routes.js b/src/bulkTransfers/routes.js new file mode 100644 index 00000000..2b2d17a7 --- /dev/null +++ b/src/bulkTransfers/routes.js @@ -0,0 +1,202 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + - Murthy Kakarlamudi murthy@modusbox.com + -------------- + ******/ + +const Handler = require('./handler') +const tags = ['api', 'metadata'] +const BaseJoi = require('joi-currency-code')(require('@hapi/joi')) +const Extension = require('@hapi/joi-date') +const Joi = BaseJoi.extend(Extension) +const transferState = ['RECEIVED', 'RESERVED', 'COMPLETED', 'ABORTED', 'SETTLED'] + +module.exports = [ + { + method: 'POST', + path: '/bulkTransfers', + handler: Handler.postBulkTransfers, + config: { + id: 'bulkTransfers', + tags: tags, + auth: null, + description: 'Bulk Transfer API.', + payload: { + failAction: 'error', + output: 'data' + }, + validate: { + headers: Joi.object({ + accept: Joi.string().optional().regex(/application\/vnd.interoperability[.]/), + 'content-type': Joi.string().required().regex(/application\/vnd.interoperability[.]/), + 'content-length': Joi.number().max(5242880), + date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(), + 'x-forwarded-for': Joi.string().optional(), + 'fspiop-source': Joi.string().required(), + 'fspiop-destination': Joi.string().required(), + 'fspiop-encryption': Joi.string().optional(), + 'fspiop-signature': Joi.string().optional(), + 'fspiop-uri': Joi.string().optional(), + 'fspiop-http-method': Joi.string().optional() + }).unknown(false).options({ stripUnknown: true }), + payload: { + bulkTransferId: Joi.string().guid().required().description('Id of bulk transfer').label('@ Bulk Transfer Id must be in a valid GUID format. @'), + bulkQuoteId: Joi.string().guid().required().description('Id of bulk transfer').label('@ Bulk Transfer Id must be in a valid GUID format. @'), + payeeFsp: Joi.string().required().min(1).max(32).description('Financial Service Provider of Payee').label('@ A valid Payee FSP number must be supplied. @'), + payerFsp: Joi.string().required().min(1).max(32).description('Financial Service Provider of Payer').label('@ A valid Payer FSP number must be supplied. @'), + individualTransfers: Joi.array().required().items({ + transferId: Joi.string().guid().required().description('Id of transfer').label('Transfer Id must be in a valid GUID format.'), + transferAmount: Joi.object().keys({ + currency: Joi.string().required().currency().description('Currency of the transfer').label('Currency needs to be a valid ISO 4217 currency code.'), + amount: Joi.string().required().regex(/^([0]|([1-9][0-9]{0,17}))([.][0-9]{0,3}[1-9])?$/).description('Amount of the transfer') + }).required().description('Amount of the transfer').label('Supplied amount fails to match the required format.'), + ilpPacket: Joi.string().required().regex(/^[A-Za-z0-9-_]+[=]{0,2}$/).min(1).max(32768).description('ilp packet').label('Supplied ILPPacket fails to match the required format.'), + condition: Joi.string().required().trim().max(48).regex(/^[A-Za-z0-9-_]{43}$/).description('Condition of transfer').label('A valid transfer condition must be supplied.'), + extensionList: Joi.object().keys({ + extension: Joi.array().items(Joi.object().keys({ + key: Joi.string().required().min(1).max(32).description('Key').label('Supplied key fails to match the required format.'), + value: Joi.string().required().min(1).max(128).description('Value').label('Supplied key value fails to match the required format.') + })).required().min(1).max(16).description('extension') + }).optional().description('Extension list') + }), + expiration: Joi.string().required().regex(/^(?:[1-9]\d{3}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)-02-29)T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(\.\d{3}))(?:Z|[+-][01]\d:[0-5]\d)$/).description('When the transfer expires').label('A valid transfer expiry date must be supplied.') + }, + failAction: (request, h, err) => { throw err } + } + } + }, + { + method: 'PUT', + path: '/bulkTransfers/{id}', + handler: Handler.putBulkTransfersById, + config: { + id: 'bulkTransfer_fulfilment', + tags: tags, + // auth: Auth.strategy(), + description: 'Fulfil a bulk transfer', + payload: { + failAction: 'error' + }, + validate: { + headers: Joi.object({ + 'content-type': Joi.string().required().regex(/application\/vnd.interoperability[.]/), + date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(), + 'x-forwarded-for': Joi.string().optional(), + 'fspiop-source': Joi.string().required(), + 'fspiop-destination': Joi.string().required(), + 'fspiop-encryption': Joi.string().optional(), + 'fspiop-signature': Joi.string().optional(), + 'fspiop-uri': Joi.string().optional(), + 'fspiop-http-method': Joi.string().optional() + }).unknown(false).options({ stripUnknown: true }), + params: { + id: Joi.string().required().description('path') + }, + payload: { + bulkTransferState: Joi.string().required().valid(transferState).description('State of the bulk transfer').label('@ Invalid bulk transfer state given. @'), + completedTimestamp: Joi.string().regex(/^(?:[1-9]\d{3}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)-02-29)T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(\.\d{3}))(?:Z|[+-][01]\d:[0-5]\d)$/).description('When the transfer was completed').label('@ A valid transfer completion date must be supplied. @'), + individualTransferResults: Joi.array().required().items({ + transferId: Joi.string().guid().required().description('Id of transfer').label('Transfer Id must be in a valid GUID format.'), + fulfilment: Joi.string().regex(/^[A-Za-z0-9-_]{43}$/).max(48).description('fulfilment of the transfer').label('@ Invalid transfer fulfilment description. @'), + extensionList: Joi.object().keys({ + extension: Joi.array().items(Joi.object().keys({ + key: Joi.string().required().min(1).max(32).description('Key').label('Supplied key fails to match the required format.'), + value: Joi.string().required().min(1).max(128).description('Value').label('Supplied key value fails to match the required format.') + })).required().min(1).max(16).description('extension') + }).optional().description('Extension list') + }), + extensionList: Joi.object().keys({ + extension: Joi.array().items(Joi.object().keys({ + key: Joi.string().required().min(1).max(32).description('Key').label('@ Supplied key fails to match the required format. @'), + value: Joi.string().required().min(1).max(128).description('Value').label('@ Supplied key value fails to match the required format. @') + })).required().min(1).max(16).description('extension') + }).optional().description('Extension list') + } + } + } + }, + { + method: 'PUT', + path: '/bulkTransfers/{id}/error', + handler: Handler.putBulkTransfersByIdError, + options: { + id: 'bulkTransfer_abort', + tags: tags, + description: 'Abort a bulk transfer', + payload: { + failAction: 'error' + }, + validate: { + headers: Joi.object({ + 'content-type': Joi.string().required().regex(/application\/vnd.interoperability[.]/), + date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(), + 'x-forwarded-for': Joi.string().optional(), + 'fspiop-source': Joi.string().required(), + 'fspiop-destination': Joi.string().optional(), + 'fspiop-encryption': Joi.string().optional(), + 'fspiop-signature': Joi.string().optional(), + 'fspiop-uri': Joi.string().optional(), + 'fspiop-http-method': Joi.string().optional() + }).unknown(false).options({ stripUnknown: true }), + params: { + id: Joi.string().required().description('path') + }, + payload: { + errorInformation: Joi.object().keys({ + errorDescription: Joi.string().required(), + errorCode: Joi.string().required().regex(/^[0-9]{4}/), + extensionList: Joi.object().keys({ + extension: Joi.array().items(Joi.object().keys({ + key: Joi.string().required().min(1).max(32).description('Key').label('@ Supplied key fails to match the required format. @'), + value: Joi.string().required().min(1).max(128).description('Value').label('@ Supplied key value fails to match the required format. @') + })).required().min(1).max(16).description('extension') + }).optional().description('Extension list') + }).required().description('Error information') + } + } + } + }, + { + method: 'GET', + path: '/bulkTransfers/correlationid/{id}', + handler: Handler.getCorrelationId, + options: { + tags: tags, + description: 'Get details based on correlationid' + } + }, + { + method: 'GET', + path: '/bulkTransfers/requests/{id}', + handler: Handler.getRequestById, + options: { + tags: tags, + description: 'Get details based on request id' + } + }, + { + method: 'GET', + path: '/bulkTransfers/callbacks/{id}', + handler: Handler.getCallbackById, + options: { + tags: tags, + description: 'Get details based on callback id' + } + } +] diff --git a/src/shared/plugins.js b/src/shared/plugins.js index a241cd5e..22868ebc 100644 --- a/src/shared/plugins.js +++ b/src/shared/plugins.js @@ -23,7 +23,7 @@ 'use strict' const Package = require('../../package.json') -const Inert = require('inert') +const Inert = require('@hapi/inert') const Vision = require('vision') const Blipp = require('blipp') const ErrorHandling = require('@mojaloop/central-services-error-handling') @@ -40,7 +40,7 @@ const registerPlugins = async (server) => { }) await server.register({ - plugin: require('good'), + plugin: require('@hapi/good'), options: { ops: { interval: 10000 diff --git a/src/shared/setup.js b/src/shared/setup.js index 5ab8eb0d..8f40a4ba 100644 --- a/src/shared/setup.js +++ b/src/shared/setup.js @@ -22,8 +22,8 @@ 'use strict' -const Hapi = require('hapi') -const Boom = require('boom') +const Hapi = require('@hapi/hapi') +const Boom = require('@hapi/boom') const Logger = require('@mojaloop/central-services-shared').Logger const Metrics = require('../lib/metrics') const RequestLogger = require('../lib/requestLogger') diff --git a/src/transactionRequests/handler.js b/src/transactionRequests/handler.js index 62f37185..c2f537f0 100644 --- a/src/transactionRequests/handler.js +++ b/src/transactionRequests/handler.js @@ -138,7 +138,7 @@ exports.delParticipantsByTypeId = function (request, h) { idMap.delete(request.params.ID) participantsCache.set(request.params.Type, idMap) } else { - let errorObject = { + const errorObject = { errorCode: 2345, errorDescription: `ID:${request.params.ID} not found` } @@ -158,17 +158,17 @@ exports.createParticipantsBatch = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - let responseObject = { + const responseObject = { partyList: [] } if (batchRequestCache.get(request.payload.requestId)) { - let errorObject = { + const errorObject = { errorCode: 2345, errorDescription: `Duplicated batch requestId:${request.payload.requestId} received` } return h.response(buildErrorObject(errorObject, [])).code(400) } else { - let newRequest = { + const newRequest = { headers: request.headers, path: request.path, method: request.method, @@ -176,7 +176,7 @@ exports.createParticipantsBatch = function (request, h) { payload: request.payload } batchRequestCache.set(request.payload.requestId, newRequest) - for (let party of request.payload.partyList) { + for (const party of request.payload.partyList) { const record = { partyList: [ { @@ -186,7 +186,7 @@ exports.createParticipantsBatch = function (request, h) { } ] } - let partyId = { + const partyId = { partyIdType: party.partyIdType, partyIdentifier: party.partyIdentifier, partySubIdOrType: party.partySubIdOrType || undefined, @@ -198,7 +198,7 @@ exports.createParticipantsBatch = function (request, h) { if (participantsCache.get(party.partyIdType)) { idMap = participantsCache.get(party.partyIdType) if (idMap.get(party.partyIdentifier)) { - let errorObject = { + const errorObject = { errorCode: 1234, errorDescription: `Participant:${party.partyIdentifier} already exists` } @@ -245,7 +245,7 @@ exports.getRequestById = function (request, h) { } const addNewRequest = function (request) { - let newRequest = { + const newRequest = { headers: request.headers, path: request.path, method: request.method, @@ -253,10 +253,10 @@ const addNewRequest = function (request) { payload: request.payload ? request.payload : undefined } if (requestsCache.get(request.params.ID)) { - let incomingRequests = requestsCache.get(request.params.ID) + const incomingRequests = requestsCache.get(request.params.ID) let foundMethod = false let count = 0 - for (let entry of incomingRequests) { + for (const entry of incomingRequests) { if (entry.method === newRequest.method) { foundMethod = true break From 560c25bda5351341997744c62a8f2784715133ac Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 24 Jul 2019 20:54:48 +0200 Subject: [PATCH 09/25] added my name to list of contributors --- src/bulkTransfers/handler.js | 2 ++ src/bulkTransfers/routes.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/bulkTransfers/handler.js b/src/bulkTransfers/handler.js index d94ea63a..fbd39bde 100644 --- a/src/bulkTransfers/handler.js +++ b/src/bulkTransfers/handler.js @@ -17,6 +17,8 @@ optionally within square brackets . * Gates Foundation - Murthy Kakarlamudi murthy@modusbox.com + - Rajiv Mothilal rajiv.mothilal@modusbox.com + -------------- ******/ diff --git a/src/bulkTransfers/routes.js b/src/bulkTransfers/routes.js index 2b2d17a7..487ef93c 100644 --- a/src/bulkTransfers/routes.js +++ b/src/bulkTransfers/routes.js @@ -17,6 +17,8 @@ optionally within square brackets . * Gates Foundation - Murthy Kakarlamudi murthy@modusbox.com + - Rajiv Mothilal rajiv.mothilal@modusbox.com + -------------- ******/ From 33bab5e86b9e43599328d02389a294126d812259 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 24 Jul 2019 20:55:23 +0200 Subject: [PATCH 10/25] Removed Murthy --- src/bulkTransfers/handler.js | 1 - src/bulkTransfers/routes.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/bulkTransfers/handler.js b/src/bulkTransfers/handler.js index fbd39bde..32dc059e 100644 --- a/src/bulkTransfers/handler.js +++ b/src/bulkTransfers/handler.js @@ -16,7 +16,6 @@ their names indented and be marked with a '-'. Email address can be added optionally within square brackets . * Gates Foundation - - Murthy Kakarlamudi murthy@modusbox.com - Rajiv Mothilal rajiv.mothilal@modusbox.com -------------- diff --git a/src/bulkTransfers/routes.js b/src/bulkTransfers/routes.js index 487ef93c..e3e9446e 100644 --- a/src/bulkTransfers/routes.js +++ b/src/bulkTransfers/routes.js @@ -16,7 +16,6 @@ their names indented and be marked with a '-'. Email address can be added optionally within square brackets . * Gates Foundation - - Murthy Kakarlamudi murthy@modusbox.com - Rajiv Mothilal rajiv.mothilal@modusbox.com -------------- From afca405b180467afdddaecc76bd663f6c58fa8f1 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Thu, 25 Jul 2019 11:00:14 +0200 Subject: [PATCH 11/25] updated to allow correct payloads --- src/bulkTransfers/routes.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/bulkTransfers/routes.js b/src/bulkTransfers/routes.js index e3e9446e..62214c2d 100644 --- a/src/bulkTransfers/routes.js +++ b/src/bulkTransfers/routes.js @@ -61,6 +61,12 @@ module.exports = [ bulkQuoteId: Joi.string().guid().required().description('Id of bulk transfer').label('@ Bulk Transfer Id must be in a valid GUID format. @'), payeeFsp: Joi.string().required().min(1).max(32).description('Financial Service Provider of Payee').label('@ A valid Payee FSP number must be supplied. @'), payerFsp: Joi.string().required().min(1).max(32).description('Financial Service Provider of Payer').label('@ A valid Payer FSP number must be supplied. @'), + extensionList: Joi.object().keys({ + extension: Joi.array().items(Joi.object().keys({ + key: Joi.string().required().min(1).max(32).description('Key').label('Supplied key fails to match the required format.'), + value: Joi.string().required().min(1).max(128).description('Value').label('Supplied key value fails to match the required format.') + })).required().min(1).max(16).description('extension') + }).optional().description('Extension list'), individualTransfers: Joi.array().required().items({ transferId: Joi.string().guid().required().description('Id of transfer').label('Transfer Id must be in a valid GUID format.'), transferAmount: Joi.object().keys({ @@ -115,6 +121,16 @@ module.exports = [ individualTransferResults: Joi.array().required().items({ transferId: Joi.string().guid().required().description('Id of transfer').label('Transfer Id must be in a valid GUID format.'), fulfilment: Joi.string().regex(/^[A-Za-z0-9-_]{43}$/).max(48).description('fulfilment of the transfer').label('@ Invalid transfer fulfilment description. @'), + errorInformation: Joi.object().keys({ + errorDescription: Joi.string().required(), + errorCode: Joi.string().required().regex(/^[0-9]{4}/), + extensionList: Joi.object().keys({ + extension: Joi.array().items(Joi.object().keys({ + key: Joi.string().required().min(1).max(32).description('Key').label('@ Supplied key fails to match the required format. @'), + value: Joi.string().required().min(1).max(128).description('Value').label('@ Supplied key value fails to match the required format. @') + })).required().min(1).max(16).description('extension') + }).optional().description('Extension list') + }).description('Error information'), extensionList: Joi.object().keys({ extension: Joi.array().items(Joi.object().keys({ key: Joi.string().required().min(1).max(32).description('Key').label('Supplied key fails to match the required format.'), From bf3304e6adbcca89a7684dd46b5f58e665dc8c03 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Fri, 30 Aug 2019 13:02:03 +0200 Subject: [PATCH 12/25] updated route validation to accept type --- package-lock.json | 2 +- package.json | 2 +- src/payer/routes.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 688abbd9..9e1c8eb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "7.4.1", + "version": "7.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5bb42a0f..1f44fad7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "7.4.1", + "version": "7.4.2", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/payer/routes.js b/src/payer/routes.js index 358b27c6..2d48b250 100644 --- a/src/payer/routes.js +++ b/src/payer/routes.js @@ -122,6 +122,7 @@ module.exports = [ tracestate: Joi.string().optional() }).unknown(false).options({ stripUnknown: true }), params: { + type: Joi.string().required().description('path'), id: Joi.string().required().description('path') }, payload: { From b811cb4a426c64dd00f98ac53734856c6d1aebe1 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Tue, 14 Jan 2020 14:33:29 +0200 Subject: [PATCH 13/25] updated for logging times on the simulator for post transfers (#126) added hapi to ncurc as version node version 10 isnt supported by latest version of hapi --- .circleci/config.yml | 6 +- .ncurc.json | 5 +- package-lock.json | 186 ++++++++++++++++++++++--------------------- package.json | 4 +- src/index.js | 1 + src/payee/handler.js | 3 +- 6 files changed, 107 insertions(+), 98 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f39776f5..6e121e2c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -342,7 +342,7 @@ jobs: command: mkdir -p ./audit/results - run: name: Check for new npm vulnerabilities - command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json + command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json - store_artifacts: path: ./audit/results prefix: audit @@ -584,7 +584,7 @@ workflows: # - test-spec filters: tags: - only: /v[0-9]+(\.[0-9]+)*\-snapshot/ + only: /v[0-9]+(\.[0-9]+)*(\-snapshot(\.[0-9]+)?)?/ branches: ignore: - /.*/ @@ -594,7 +594,7 @@ workflows: - build-snapshot filters: tags: - only: /v[0-9]+(\.[0-9]+)*\-snapshot/ + only: /v[0-9]+(\.[0-9]+)*(\-snapshot(\.[0-9]+)?)?/ branches: ignore: - /.*/ diff --git a/.ncurc.json b/.ncurc.json index 1ebcafd3..489a7bf4 100644 --- a/.ncurc.json +++ b/.ncurc.json @@ -2,6 +2,9 @@ "reject": [ "hapi-swagger", "@hapi/joi", - "@hapi/inert" + "@hapi/inert", + "@hapi/good", + "@hapi/vision", + "@hapi/hapi" ] } diff --git a/package-lock.json b/package-lock.json index 25c245cf..e798478f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0", + "version": "8.8.0-snapshot.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -691,40 +691,45 @@ } }, "@mojaloop/central-services-shared": { - "version": "8.7.2", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.7.2.tgz", - "integrity": "sha512-iyoFkmxiGL4S4756kZl/tr7xfX2QRqJ9Ibyw/Y8kM43vnXci2DQp02+OZT0poU8SiwRk9DSJNeqfl+yYAJ89cg==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.8.0.tgz", + "integrity": "sha512-OsnUHh+vwldE9i2oaI4BqntoybodCUuM3zVPqfYHmVxATnySLPd4P7KGaTIzVOVbfY+I0uKpoIGjgzEtjjO1Yg==", "requires": { "@hapi/catbox": "10.2.3", - "@hapi/catbox-memory": "4.1.1", + "@hapi/catbox-memory": "5.0.0", "@mojaloop/central-services-error-handling": "8.6.2", "@mojaloop/central-services-logger": "8.6.0", - "@mojaloop/event-sdk": "8.6.2", - "axios": "0.19.0", + "@mojaloop/event-sdk": "8.7.0", + "axios": "0.19.1", "base64url": "3.0.1", "clone": "2.1.2", - "data-urls": "1.1.0", + "data-urls": "2.0.0", "immutable": "3.8.2", "lodash": "4.17.15", - "mustache": "3.1.0", + "mustache": "3.2.1", "raw-body": "2.4.1" }, "dependencies": { - "axios": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", - "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "@hapi/catbox-memory": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@hapi/catbox-memory/-/catbox-memory-5.0.0.tgz", + "integrity": "sha512-ByuxVJPHNaXwLzbBv4GdTr6ccpe1nG+AfYt+8ftDWEJY7EWBWzD+Klhy5oPTDGzU26pNUh1e7fcYI1ILZRxAXQ==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" + "@hapi/boom": "9.x.x", + "@hapi/hoek": "9.x.x" } + }, + "@hapi/hoek": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.2.tgz", + "integrity": "sha512-LyibKv2QnD9BPI5g2L+g85yiIPv3ajYpENGFgy4u0xCLPhXWG1Zdx29neSB8sgX0/wz6k5TMjHzTwJ6+DaBYOA==" } } }, "@mojaloop/event-sdk": { - "version": "8.6.2", - "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-8.6.2.tgz", - "integrity": "sha512-ZeQffxnRNU7+/2PF2viuje2F5cz5EvvDkfajYZJtL9SBPxPqHlXxEV+J3FmHsM8JMDMr5j8rDwz++mVCyYj8Kw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-8.7.0.tgz", + "integrity": "sha512-pJX9R7lDUt0UgE+2cddcJ6pCpLzX/J3fV5lO84Es+mK/pym2W7QVPcJF3flK7I46tYJ9fNC/Z+wYnmmLMbFuYQ==", "requires": { "@grpc/proto-loader": "0.5.3", "@mojaloop/central-services-logger": "8.6.0", @@ -738,7 +743,7 @@ "protobufjs": "6.8.8", "rc": "1.2.8", "serialize-error": "4.1.0", - "sinon": "7.5.0", + "sinon": "8.0.4", "traceparent": "1.0.0", "tslib": "1.10.0", "uuid4": "1.1.4" @@ -846,22 +851,22 @@ } }, "@sinonjs/formatio": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.2.tgz", - "integrity": "sha512-B8SEsgd8gArBLMD6zpRw3juQ2FVSsmdd7qlevyDqzS9WTCtvF55/gAL+h6gue8ZvPYcdiPdvueM/qm//9XzyTQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-4.0.1.tgz", + "integrity": "sha512-asIdlLFrla/WZybhm0C8eEzaDNNrzymiTqHMeJl6zPW2881l3uuVRpm0QlRQEjqYWv6CcKMGYME3LbrLJsORBw==", "requires": { "@sinonjs/commons": "^1", - "@sinonjs/samsam": "^3.1.0" + "@sinonjs/samsam": "^4.2.0" } }, "@sinonjs/samsam": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", - "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-4.2.2.tgz", + "integrity": "sha512-z9o4LZUzSD9Hl22zV38aXNykgFeVj8acqfFabCY6FY83n/6s/XwNJyYYldz6/9lBJanpno9h+oL6HTISkviweA==", "requires": { - "@sinonjs/commons": "^1.3.0", - "array-from": "^2.1.1", - "lodash": "^4.17.15" + "@sinonjs/commons": "^1.6.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" } }, "@sinonjs/text-encoding": { @@ -1043,11 +1048,6 @@ "sprintf-js": "~1.0.2" } }, - "array-from": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=" - }, "array-includes": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", @@ -1713,13 +1713,13 @@ } }, "data-urls": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.1.0.tgz", - "integrity": "sha512-YTWYI9se1P55u58gL5GkQHW4P6VJBJ5iBT+B5a7i2Tjadhv52paJG0qHX4A0OR6/t52odI64KP2YvFpkDOi3eQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", + "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", "requires": { - "abab": "^2.0.0", - "whatwg-mimetype": "^2.2.0", - "whatwg-url": "^7.0.0" + "abab": "^2.0.3", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^8.0.0" } }, "debug": { @@ -1843,9 +1843,9 @@ } }, "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" }, "djv": { "version": "2.1.2", @@ -3670,11 +3670,6 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" }, - "is-buffer": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", - "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" - }, "is-callable": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", @@ -4226,9 +4221,12 @@ } }, "lolex": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", - "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==" + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-5.1.2.tgz", + "integrity": "sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A==", + "requires": { + "@sinonjs/commons": "^1.7.0" + } }, "long": { "version": "3.2.0", @@ -4508,9 +4506,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mustache": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.1.0.tgz", - "integrity": "sha512-3Bxq1R5LBZp7fbFPZzFe5WN4s0q3+gxZaZuZVY+QctYJiCiVgXHOTIC0/HgZuOPFt/6BQcx5u0H2CUOxT/RoGQ==" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.2.1.tgz", + "integrity": "sha512-RERvMFdLpaFfSRIEe632yDm5nsd0SDKn8hGmcUwswnyiE5mtdZLDybtHAz6hjJhawokF0hXvGLtx9mrQfm6FkA==" }, "mute-stream": { "version": "0.0.8", @@ -4547,25 +4545,16 @@ "dev": true }, "nise": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.3.tgz", - "integrity": "sha512-Ymbac/94xeIrMf59REBPOv0thr+CJVFMhrlAkW/gjCIE58BGQdCj0x7KRCb3yz+Ga2Rz3E9XXSvUyyxqqhjQAQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nise/-/nise-3.0.1.tgz", + "integrity": "sha512-fYcH9y0drBGSoi88kvhpbZEsenX58Yr+wOJ4/Mi1K4cy+iGP/a73gNoyNhu5E9QxPdgTlVChfIaAlnyOy/gHUA==", "requires": { - "@sinonjs/formatio": "^3.2.1", + "@sinonjs/commons": "^1.7.0", + "@sinonjs/formatio": "^4.0.1", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "lolex": "^5.0.1", "path-to-regexp": "^1.7.0" - }, - "dependencies": { - "lolex": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-5.1.2.tgz", - "integrity": "sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A==", - "requires": { - "@sinonjs/commons": "^1.7.0" - } - } } }, "node-alias": { @@ -5913,17 +5902,32 @@ } }, "sinon": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", - "integrity": "sha512-AoD0oJWerp0/rY9czP/D6hDTTUYGpObhZjMpd7Cl/A6+j0xBE+ayL/ldfggkBXUs0IkvIiM1ljM8+WkOc5k78Q==", - "requires": { - "@sinonjs/commons": "^1.4.0", - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/samsam": "^3.3.3", - "diff": "^3.5.0", - "lolex": "^4.2.0", - "nise": "^1.5.2", - "supports-color": "^5.5.0" + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-8.0.4.tgz", + "integrity": "sha512-cFsmgmvsgFb87e7SV7IcekogITlHX2KmlplyI9Pda0FH1Z8Ms/kWbpLs25Idp0m6ZJ3HEEjhaYYXbcTtWWUn4w==", + "requires": { + "@sinonjs/commons": "^1.7.0", + "@sinonjs/formatio": "^4.0.1", + "@sinonjs/samsam": "^4.2.1", + "diff": "^4.0.1", + "lolex": "^5.1.2", + "nise": "^3.0.1", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "requires": { + "has-flag": "^4.0.0" + } + } } }, "sisteransi": { @@ -6396,11 +6400,11 @@ } }, "tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.0.tgz", + "integrity": "sha512-LrErSqfhdUw73AC/eXV2fEmNkvgSYxfm5lvxnLvuVgoVDknvD28Pa5FeDGc8RuVouDxUD3GnHHFv7xnBp7As5w==", "requires": { - "punycode": "^2.1.0" + "punycode": "^2.1.1" } }, "traceparent": { @@ -6609,9 +6613,9 @@ } }, "webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", + "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==" }, "whatwg-mimetype": { "version": "2.3.0", @@ -6619,13 +6623,13 @@ "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==" }, "whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.0.0.tgz", + "integrity": "sha512-41ou2Dugpij8/LPO5Pq64K5q++MnRCBpEHvQr26/mArEKTkCV5aoXIqyhuYtE0pkqScXwhf2JP57rkRTYM29lQ==", "requires": { "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" + "tr46": "^2.0.0", + "webidl-conversions": "^5.0.0" } }, "which": { diff --git a/package.json b/package.json index d131155a..dae204d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0", + "version": "8.8.0-snapshot.1", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", @@ -41,7 +41,7 @@ "@mojaloop/central-services-error-handling": "8.6.2", "@mojaloop/central-services-logger": "8.6.0", "@mojaloop/central-services-metrics": "8.3.0", - "@mojaloop/central-services-shared": "8.7.2", + "@mojaloop/central-services-shared": "8.8.0", "axios": "0.19.1", "base64url": "3.0.1", "blipp": "4.0.1", diff --git a/src/index.js b/src/index.js index bab74b26..01a58cc9 100644 --- a/src/index.js +++ b/src/index.js @@ -25,6 +25,7 @@ const Routes = require('./routes') const Setup = require('.' + '/shared/setup') +process.env.UV_THREADPOOL_SIZE = 12 module.exports = Setup.initialize({ service: 'api', diff --git a/src/payee/handler.js b/src/payee/handler.js index 93d37234..237c8d8b 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -307,7 +307,7 @@ exports.postTransfers = async function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - + Logger.info(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) Logger.debug(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${request.method} ${request.path} ${request.payload.transferId}` @@ -372,6 +372,7 @@ exports.postTransfers = async function (request, h) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } + Logger.info(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, From f806dcecaab0415a645dd8829be89f554d340744 Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Tue, 14 Jan 2020 22:15:01 +0200 Subject: [PATCH 14/25] Feature/#1140 host logging enhancement optimizations (#127) * updated for logging times on the simulator for post transfers added hapi to ncurc as version node version 10 isnt supported by latest version of hapi * fix for end log of simulator not displaying --- package-lock.json | 2 +- package.json | 2 +- src/payee/handler.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e798478f..aa1ef6c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.1", + "version": "8.8.0-snapshot.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dae204d6..8b9a8205 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.1", + "version": "8.8.0-snapshot.2", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/payee/handler.js b/src/payee/handler.js index 237c8d8b..d6583317 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -368,7 +368,7 @@ exports.postTransfers = async function (request, h) { // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) const res = await sendRequest(url, opts, request.span) // Logger.info(`response: ${res.status}`) - if ((res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) || (res.status !== Enums.Http.ReturnCodes.OK.CODE)) { + if ((res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) && (res.status !== Enums.Http.ReturnCodes.OK.CODE)) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } From c83df99ca8a6b3c86fde380ef6c361a8de2a68da Mon Sep 17 00:00:00 2001 From: Valentin Date: Wed, 15 Jan 2020 12:20:17 +0200 Subject: [PATCH 15/25] updated shared lib version --- package-lock.json | 68 +++++++++++++++++++++++++++++++++++------------ package.json | 6 ++--- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index aa1ef6c6..f43f082c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.2", + "version": "8.8.0-snapshot.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -664,11 +664,11 @@ "optional": true }, "@mojaloop/central-services-error-handling": { - "version": "8.6.2", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-error-handling/-/central-services-error-handling-8.6.2.tgz", - "integrity": "sha512-VaIkDLNkICvb9EMvKQKXPuaxhsOhrcnJbAO6DrQKuqYl3hq7FD/4w6bAmOhJ6OEUNVbn3Baukk0hHigKcv2YGw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-error-handling/-/central-services-error-handling-8.7.0.tgz", + "integrity": "sha512-3CanhajjN1l3dHy4P2f5IM8DGe6A+aXMn1v46RDfFwwKehfoJfmwV2sYNumXWUDRmEYsYL4L3IdoY+E8hHTZzA==", "requires": { - "@mojaloop/sdk-standard-components": "8.6.1", + "@mojaloop/sdk-standard-components": "8.6.7", "lodash": "4.17.15" } }, @@ -691,15 +691,15 @@ } }, "@mojaloop/central-services-shared": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.8.0.tgz", - "integrity": "sha512-OsnUHh+vwldE9i2oaI4BqntoybodCUuM3zVPqfYHmVxATnySLPd4P7KGaTIzVOVbfY+I0uKpoIGjgzEtjjO1Yg==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.8.1.tgz", + "integrity": "sha512-FRBYdjVZlkVJ/AD8yDNTUwnKQ8PCTsxIuAQCT4wPKINedLSgXAcJ+bV27J8nK+1iETSHCar+IVrv3+aRG9Q54Q==", "requires": { "@hapi/catbox": "10.2.3", "@hapi/catbox-memory": "5.0.0", - "@mojaloop/central-services-error-handling": "8.6.2", + "@mojaloop/central-services-error-handling": "8.7.0", "@mojaloop/central-services-logger": "8.6.0", - "@mojaloop/event-sdk": "8.7.0", + "@mojaloop/event-sdk": "8.8.1-snapshot.2", "axios": "0.19.1", "base64url": "3.0.1", "clone": "2.1.2", @@ -723,13 +723,46 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.2.tgz", "integrity": "sha512-LyibKv2QnD9BPI5g2L+g85yiIPv3ajYpENGFgy4u0xCLPhXWG1Zdx29neSB8sgX0/wz6k5TMjHzTwJ6+DaBYOA==" + }, + "@mojaloop/central-services-error-handling": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-error-handling/-/central-services-error-handling-8.7.0.tgz", + "integrity": "sha512-3CanhajjN1l3dHy4P2f5IM8DGe6A+aXMn1v46RDfFwwKehfoJfmwV2sYNumXWUDRmEYsYL4L3IdoY+E8hHTZzA==", + "requires": { + "@mojaloop/sdk-standard-components": "8.6.7", + "lodash": "4.17.15" + } + }, + "@mojaloop/sdk-standard-components": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/@mojaloop/sdk-standard-components/-/sdk-standard-components-8.6.7.tgz", + "integrity": "sha512-pDojVFEkHYGp2znje9qUQor1WsUx9ue5v3ToxBrl60X/Ydq//KbraknnedHvpAhwkxXS0SkaJwQp9Qc3sWau1Q==", + "requires": { + "base64url": "^3.0.1", + "ilp-packet": "2.2.0", + "jsonwebtoken": "^8.5.1", + "jws": "^3.2.2", + "request": "^2.34", + "request-promise-native": "^1.0.7" + } + }, + "ilp-packet": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ilp-packet/-/ilp-packet-2.2.0.tgz", + "integrity": "sha1-qHJcwmMxxuLGU1OKEGPVUBQwXjE=", + "requires": { + "bignumber.js": "^5.0.0", + "extensible-error": "^1.0.2", + "long": "^3.2.0", + "oer-utils": "^1.3.2" + } } } }, "@mojaloop/event-sdk": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-8.7.0.tgz", - "integrity": "sha512-pJX9R7lDUt0UgE+2cddcJ6pCpLzX/J3fV5lO84Es+mK/pym2W7QVPcJF3flK7I46tYJ9fNC/Z+wYnmmLMbFuYQ==", + "version": "8.8.1-snapshot.2", + "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-8.8.1-snapshot.2.tgz", + "integrity": "sha512-ufq+PCbASUfVA24jJ7yFKBUNVVeayop9Us8eKh05Ow5AD+JNfoulVDKPnhqDplTuRQ8Jss88u2kjPmcx9B8IXA==", "requires": { "@grpc/proto-loader": "0.5.3", "@mojaloop/central-services-logger": "8.6.0", @@ -746,7 +779,8 @@ "sinon": "8.0.4", "traceparent": "1.0.0", "tslib": "1.10.0", - "uuid4": "1.1.4" + "uuid4": "1.1.4", + "winston": "3.2.1" }, "dependencies": { "parse-strings-in-object": { @@ -757,9 +791,9 @@ } }, "@mojaloop/sdk-standard-components": { - "version": "8.6.1", - "resolved": "https://registry.npmjs.org/@mojaloop/sdk-standard-components/-/sdk-standard-components-8.6.1.tgz", - "integrity": "sha512-KN8OO+uwoIfUZG9XamUNtY+doXlaNSae9ZZDpNhYjsVkaR1uE6TKPXiisH1gHMGkr9nNMCw8ON6EQr8s4jSO+A==", + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/@mojaloop/sdk-standard-components/-/sdk-standard-components-8.6.7.tgz", + "integrity": "sha512-pDojVFEkHYGp2znje9qUQor1WsUx9ue5v3ToxBrl60X/Ydq//KbraknnedHvpAhwkxXS0SkaJwQp9Qc3sWau1Q==", "requires": { "base64url": "^3.0.1", "ilp-packet": "2.2.0", diff --git a/package.json b/package.json index 8b9a8205..253ad6ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.2", + "version": "8.8.0-snapshot.3", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", @@ -38,10 +38,10 @@ "@hapi/joi": "16.1.8", "@hapi/joi-date": "2.0.1", "@hapi/vision": "5.5.4", - "@mojaloop/central-services-error-handling": "8.6.2", + "@mojaloop/central-services-error-handling": "8.7.0", "@mojaloop/central-services-logger": "8.6.0", "@mojaloop/central-services-metrics": "8.3.0", - "@mojaloop/central-services-shared": "8.8.0", + "@mojaloop/central-services-shared": "8.8.1", "axios": "0.19.1", "base64url": "3.0.1", "blipp": "4.0.1", From 3b943db357c0a63ce72734bad3ae79a9b92e3d6e Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Wed, 15 Jan 2020 15:42:58 +0000 Subject: [PATCH 16/25] Feature/#1140 host logging enhancement optimizations (#128) * updated for logging times on the simulator for post transfers added hapi to ncurc as version node version 10 isnt supported by latest version of hapi * fix for end log of simulator not displaying * added log statements to calculate sim time for put transfers --- package-lock.json | 2 +- package.json | 2 +- src/payer/handler.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f43f082c..1d6b3898 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.3", + "version": "8.8.0-snapshot.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 253ad6ee..e835f618 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.3", + "version": "8.8.0-snapshot.4", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/payer/handler.js b/src/payer/handler.js index b54473e9..b189bca2 100644 --- a/src/payer/handler.js +++ b/src/payer/handler.js @@ -162,6 +162,7 @@ exports.putTransfersById = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() + Logger.info(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) @@ -178,6 +179,7 @@ exports.putTransfersById = function (request, h) { // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) + Logger.info(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } From a778296a956350a5eeb002fdbbfcbaa04e12af1f Mon Sep 17 00:00:00 2001 From: Rajiv Mothilal Date: Mon, 27 Jan 2020 22:46:31 +0200 Subject: [PATCH 17/25] Feature/#1140 host logging enhancement optimizations (#135) * updated for logging times on the simulator for post transfers added hapi to ncurc as version node version 10 isnt supported by latest version of hapi * fix for end log of simulator not displaying * added log statements to calculate sim time for put transfers * changed logging to errors * updated version * updated license --- package-lock.json | 365 +++++++++++++++++++++++++++++++++++++------ package.json | 11 +- src/payee/handler.js | 19 ++- src/payer/handler.js | 4 +- 4 files changed, 332 insertions(+), 67 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d6b3898..58e6acf5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.0-snapshot.4", + "version": "v8.8.2-snapshot.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -683,30 +683,31 @@ } }, "@mojaloop/central-services-metrics": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-metrics/-/central-services-metrics-8.3.0.tgz", - "integrity": "sha512-T3luQbyJ6DBFmexhnkONy8XY0u0oc2fi1L7DK5UfWxJmVPTMLsC5d7p2YFOu79n9i2c+nrD5eZN5bxe1sz9f9A==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-metrics/-/central-services-metrics-8.8.0.tgz", + "integrity": "sha512-rkwSHs2TaKsQ+xwh/KP5nv8lBbXpfQOq+0HfVbDpiI85d92yMmfhQFlBZ8ypxxXHejHP2cfUcroGmZ7ZHdk9Ug==", "requires": { "prom-client": "11.5.3" } }, "@mojaloop/central-services-shared": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.8.1.tgz", - "integrity": "sha512-FRBYdjVZlkVJ/AD8yDNTUwnKQ8PCTsxIuAQCT4wPKINedLSgXAcJ+bV27J8nK+1iETSHCar+IVrv3+aRG9Q54Q==", + "version": "8.8.3", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.8.3.tgz", + "integrity": "sha512-YnVmM1e8+SlbhhrwdWNaMVXFp/SmboJVz94qjvd+Ww1Rl67Kp6q4RezykuI2FAUwCxAi8InUCQ6JGWmXMaPcig==", "requires": { "@hapi/catbox": "10.2.3", "@hapi/catbox-memory": "5.0.0", "@mojaloop/central-services-error-handling": "8.7.0", "@mojaloop/central-services-logger": "8.6.0", + "@mojaloop/central-services-metrics": "8.8.0", "@mojaloop/event-sdk": "8.8.1-snapshot.2", - "axios": "0.19.1", + "axios": "0.19.2", "base64url": "3.0.1", "clone": "2.1.2", "data-urls": "2.0.0", "immutable": "3.8.2", "lodash": "4.17.15", - "mustache": "3.2.1", + "mustache": "4.0.0", "raw-body": "2.4.1" }, "dependencies": { @@ -723,39 +724,6 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.2.tgz", "integrity": "sha512-LyibKv2QnD9BPI5g2L+g85yiIPv3ajYpENGFgy4u0xCLPhXWG1Zdx29neSB8sgX0/wz6k5TMjHzTwJ6+DaBYOA==" - }, - "@mojaloop/central-services-error-handling": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-error-handling/-/central-services-error-handling-8.7.0.tgz", - "integrity": "sha512-3CanhajjN1l3dHy4P2f5IM8DGe6A+aXMn1v46RDfFwwKehfoJfmwV2sYNumXWUDRmEYsYL4L3IdoY+E8hHTZzA==", - "requires": { - "@mojaloop/sdk-standard-components": "8.6.7", - "lodash": "4.17.15" - } - }, - "@mojaloop/sdk-standard-components": { - "version": "8.6.7", - "resolved": "https://registry.npmjs.org/@mojaloop/sdk-standard-components/-/sdk-standard-components-8.6.7.tgz", - "integrity": "sha512-pDojVFEkHYGp2znje9qUQor1WsUx9ue5v3ToxBrl60X/Ydq//KbraknnedHvpAhwkxXS0SkaJwQp9Qc3sWau1Q==", - "requires": { - "base64url": "^3.0.1", - "ilp-packet": "2.2.0", - "jsonwebtoken": "^8.5.1", - "jws": "^3.2.2", - "request": "^2.34", - "request-promise-native": "^1.0.7" - } - }, - "ilp-packet": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ilp-packet/-/ilp-packet-2.2.0.tgz", - "integrity": "sha1-qHJcwmMxxuLGU1OKEGPVUBQwXjE=", - "requires": { - "bignumber.js": "^5.0.0", - "extensible-error": "^1.0.2", - "long": "^3.2.0", - "oer-utils": "^1.3.2" - } } } }, @@ -1184,9 +1152,9 @@ "integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==" }, "axios": { - "version": "0.19.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.1.tgz", - "integrity": "sha512-Yl+7nfreYKaLRvAvjNPkvfjnQHJM1yLBY3zhqAwcJSwR/6ETkanUgylgtIvkvz0xJ+p/vZuNw8X7Hnb7Whsbpw==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", "requires": { "follow-redirects": "1.5.10" } @@ -2581,6 +2549,15 @@ "tweetnacl": "^0.14.1" } }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, "flat-cache": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", @@ -2679,6 +2656,12 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, "get-stdin": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", @@ -3704,6 +3687,12 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" }, + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true + }, "is-callable": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", @@ -4347,6 +4336,34 @@ } } }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + } + } + }, "merge-object-files": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-object-files/-/merge-object-files-2.0.0.tgz", @@ -4540,9 +4557,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mustache": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.2.1.tgz", - "integrity": "sha512-RERvMFdLpaFfSRIEe632yDm5nsd0SDKn8hGmcUwswnyiE5mtdZLDybtHAz6hjJhawokF0hXvGLtx9mrQfm6FkA==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.0.0.tgz", + "integrity": "sha512-FJgjyX/IVkbXBXYUwH+OYwQKqWpFPLaLVESd70yHjSDunwzV2hZOoTBvPf4KLoxesUzzyfTH6F784Uqd7Wm5yA==" }, "mute-stream": { "version": "0.0.8", @@ -4655,9 +4672,9 @@ "dev": true }, "npm-audit-resolver": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/npm-audit-resolver/-/npm-audit-resolver-2.1.0.tgz", - "integrity": "sha512-8VaG7p3tbP0+JbpDKldQueZvh9oUcr3H/C2FIbcIhYBANAQ1kCIhUqYOxVFjG3RKEV9G1coIFzUOxBoPyyejNg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/npm-audit-resolver/-/npm-audit-resolver-2.2.0.tgz", + "integrity": "sha512-nBhxrc0Y34vIFl38G42PkWSBEbOAL3Gg6aRxm1hYzM4Vm+Rv0ozALj2LixdeytkUC2OGWP4QqCF0fKAb14NnPQ==", "dev": true, "requires": { "audit-resolve-core": "^1.1.7", @@ -4666,7 +4683,8 @@ "jsonlines": "^0.1.1", "read": "^1.0.7", "spawn-shell": "^2.1.0", - "yargs-parser": "^13.1.1" + "yargs-parser": "^13.1.1", + "yargs-unparser": "^1.5.0" } }, "npm-bundled": { @@ -5130,12 +5148,24 @@ "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", "dev": true }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "dev": true }, + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -5753,12 +5783,24 @@ "tough-cookie": "^2.3.3" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", "dev": true }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, "requireg": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/requireg/-/requireg-0.2.2.tgz", @@ -5901,6 +5943,12 @@ "type-fest": "^0.3.0" } }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, "setprototypeof": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", @@ -6675,6 +6723,12 @@ "isexe": "^2.0.0" } }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, "widest-line": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-2.0.1.tgz", @@ -6852,6 +6906,213 @@ } } }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "dev": true, + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, + "p-limit": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", + "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, "z-schema": { "version": "3.25.1", "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.25.1.tgz", diff --git a/package.json b/package.json index e835f618..9a80dd22 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "sims", - "version": "8.8.0-snapshot.4", + "version": "v8.8.2-snapshot.1", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", + "license": "Apache-2.0", "contributors": [ "Georgi Georgiev ", "Miguel de Barros ", @@ -40,9 +41,9 @@ "@hapi/vision": "5.5.4", "@mojaloop/central-services-error-handling": "8.7.0", "@mojaloop/central-services-logger": "8.6.0", - "@mojaloop/central-services-metrics": "8.3.0", - "@mojaloop/central-services-shared": "8.8.1", - "axios": "0.19.1", + "@mojaloop/central-services-metrics": "8.8.0", + "@mojaloop/central-services-shared": "8.8.3", + "axios": "0.19.2", "base64url": "3.0.1", "blipp": "4.0.1", "five-bells-condition": "5.0.1", @@ -58,7 +59,7 @@ "devDependencies": { "pre-commit": "1.2.2", "standard": "14.3.1", - "npm-audit-resolver": "2.1.0", + "npm-audit-resolver": "2.2.0", "npm-check-updates": "4.0.1" } } diff --git a/src/payee/handler.js b/src/payee/handler.js index d6583317..1ff5a246 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -307,7 +307,7 @@ exports.postTransfers = async function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) + Logger.error(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) Logger.debug(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${request.method} ${request.path} ${request.payload.transferId}` @@ -366,13 +366,16 @@ exports.postTransfers = async function (request, h) { } // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) - const res = await sendRequest(url, opts, request.span) - // Logger.info(`response: ${res.status}`) - if ((res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) && (res.status !== Enums.Http.ReturnCodes.OK.CODE)) { - // TODO: how does one identify the failed response? - throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) - } - Logger.info(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) + setImmediate(async () => { + const res = await sendRequest(url, opts, request.span) + // Logger.info(`response: ${res.status}`) + if ((res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) && (res.status !== Enums.Http.ReturnCodes.OK.CODE)) { + // TODO: how does one identify the failed response? + throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) + } + }) + + Logger.error(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, diff --git a/src/payer/handler.js b/src/payer/handler.js index b189bca2..0425fe1c 100644 --- a/src/payer/handler.js +++ b/src/payer/handler.js @@ -162,7 +162,7 @@ exports.putTransfersById = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) + Logger.error(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) @@ -179,7 +179,7 @@ exports.putTransfersById = function (request, h) { // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) - Logger.info(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) + Logger.error(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } From eac12de885a7b21ca8d627e22341cdc713882bfb Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 28 Jan 2020 10:11:09 +0200 Subject: [PATCH 18/25] wip --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 01a58cc9..9461d9da 100644 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,6 @@ process.env.UV_THREADPOOL_SIZE = 12 module.exports = Setup.initialize({ service: 'api', - port: 8444, + port: 1080, modules: [Routes] }) From c2b8130722af51a53bb208db6fc87902cf34132b Mon Sep 17 00:00:00 2001 From: Valentin Date: Thu, 6 Feb 2020 20:46:05 +0200 Subject: [PATCH 19/25] removed span tags and info from sendRequest --- package.json | 2 +- src/lib/sendRequest.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9a80dd22..82c0ea58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "v8.8.2-snapshot.1", + "version": "8.8.2-snapshot.2", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/lib/sendRequest.js b/src/lib/sendRequest.js index 5e0bd49d..ff523921 100644 --- a/src/lib/sendRequest.js +++ b/src/lib/sendRequest.js @@ -28,15 +28,15 @@ const Logger = require('@mojaloop/central-services-logger') const request = require('axios') const { pickBy, identity } = require('lodash') -const { getTagsFromFSPIOPHeaders } = require('./events') +// const { getTagsFromFSPIOPHeaders } = require('./events') module.exports = async (url, opts, span) => { Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) let optionsWithCleanHeaders = Object.assign({}, opts, { headers: pickBy(opts.headers, identity) }) if (span) { optionsWithCleanHeaders = span.injectContextToHttpRequest(optionsWithCleanHeaders) - span.setTags(getTagsFromFSPIOPHeaders(optionsWithCleanHeaders)) - span.info(optionsWithCleanHeaders) + // span.setTags(getTagsFromFSPIOPHeaders(optionsWithCleanHeaders)) + // span.info(optionsWithCleanHeaders) } const res = await request(url, optionsWithCleanHeaders) Logger.info((new Date().toISOString()), 'response: ', res.status) From 7ada3464b94a2b1ba2a1e61a1e3e9bb64af4784c Mon Sep 17 00:00:00 2001 From: Valentin Date: Thu, 6 Feb 2020 21:00:39 +0200 Subject: [PATCH 20/25] port back to 8444 --- package-lock.json | 2 +- package.json | 2 +- src/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58e6acf5..85e737ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "v8.8.2-snapshot.1", + "version": "8.8.2-snapshot.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 82c0ea58..9d9a5ce5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "8.8.2-snapshot.2", + "version": "8.8.2-snapshot.3", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/index.js b/src/index.js index 9461d9da..01a58cc9 100644 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,6 @@ process.env.UV_THREADPOOL_SIZE = 12 module.exports = Setup.initialize({ service: 'api', - port: 1080, + port: 8444, modules: [Routes] }) From c64ba0ce0b27923e0d8a03e6e5234f603db3a368 Mon Sep 17 00:00:00 2001 From: Yosh Kemu Date: Tue, 10 Mar 2020 11:35:54 +0000 Subject: [PATCH 21/25] updated dependency to central-services-shared@9.3.2-snapshot --- package-lock.json | 269 ++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 202 insertions(+), 69 deletions(-) diff --git a/package-lock.json b/package-lock.json index 85e737ce..c0ad2b96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -691,16 +691,16 @@ } }, "@mojaloop/central-services-shared": { - "version": "8.8.3", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-8.8.3.tgz", - "integrity": "sha512-YnVmM1e8+SlbhhrwdWNaMVXFp/SmboJVz94qjvd+Ww1Rl67Kp6q4RezykuI2FAUwCxAi8InUCQ6JGWmXMaPcig==", + "version": "9.3.2-snapshot", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-9.3.2-snapshot.tgz", + "integrity": "sha512-4Va+3d+F7xXgGmtsEfx5kMrYZRgc12ypk1IawUZ1BnrUzN8HLt6SxgBwidtHYMVqnLQK/ov4aQrKCpFMXc23VQ==", "requires": { - "@hapi/catbox": "10.2.3", + "@hapi/catbox": "11.0.1", "@hapi/catbox-memory": "5.0.0", - "@mojaloop/central-services-error-handling": "8.7.0", - "@mojaloop/central-services-logger": "8.6.0", - "@mojaloop/central-services-metrics": "8.8.0", - "@mojaloop/event-sdk": "8.8.1-snapshot.2", + "@mojaloop/central-services-error-handling": "9.1.0", + "@mojaloop/central-services-logger": "9.1.0", + "@mojaloop/central-services-metrics": "9.1.0", + "@mojaloop/event-sdk": "9.3.0-snapshot", "axios": "0.19.2", "base64url": "3.0.1", "clone": "2.1.2", @@ -708,9 +708,29 @@ "immutable": "3.8.2", "lodash": "4.17.15", "mustache": "4.0.0", - "raw-body": "2.4.1" + "raw-body": "2.4.1", + "winston": "^3.2.1" }, "dependencies": { + "@hapi/address": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@hapi/address/-/address-4.0.0.tgz", + "integrity": "sha512-GDDpkCdSUfkQCznmWUHh9dDN85BWf/V8TFKQ2JLuHdGB4Yy3YTEGBzZxoBNxfNBEvreSR/o+ZxBBSNNEVzY+lQ==", + "requires": { + "@hapi/hoek": "^9.0.0" + } + }, + "@hapi/catbox": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@hapi/catbox/-/catbox-11.0.1.tgz", + "integrity": "sha512-CsdannMSzWqLcJ7rXT55JGAzoR+BPXesKn9POOrF0A0wsumbUwHP7vxBUH/21YitcM/dLxjUfphkRAQT+XaoyQ==", + "requires": { + "@hapi/boom": "9.x.x", + "@hapi/hoek": "9.x.x", + "@hapi/joi": "17.x.x", + "@hapi/podium": "4.x.x" + } + }, "@hapi/catbox-memory": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@hapi/catbox-memory/-/catbox-memory-5.0.0.tgz", @@ -720,41 +740,157 @@ "@hapi/hoek": "9.x.x" } }, + "@hapi/formula": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-2.0.0.tgz", + "integrity": "sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A==" + }, "@hapi/hoek": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.2.tgz", - "integrity": "sha512-LyibKv2QnD9BPI5g2L+g85yiIPv3ajYpENGFgy4u0xCLPhXWG1Zdx29neSB8sgX0/wz6k5TMjHzTwJ6+DaBYOA==" + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.3.tgz", + "integrity": "sha512-jKtjLLDiH95b002sJVc5c74PE6KKYftuyVdVmsuYId5stTaWcRFqE+5ukZI4gDUKjGn8wv2C3zPn3/nyjEI7gg==" + }, + "@hapi/joi": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-17.1.0.tgz", + "integrity": "sha512-ob67RcPlwRWxBzLCnWvcwx5qbwf88I3ykD7gcJLWOTRfLLgosK7r6aeChz4thA3XRvuBfI0KB1tPVl2EQFlPXw==", + "requires": { + "@hapi/address": "^4.0.0", + "@hapi/formula": "^2.0.0", + "@hapi/hoek": "^9.0.0", + "@hapi/pinpoint": "^2.0.0", + "@hapi/topo": "^5.0.0" + } + }, + "@hapi/pinpoint": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-2.0.0.tgz", + "integrity": "sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw==" + }, + "@hapi/podium": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@hapi/podium/-/podium-4.1.0.tgz", + "integrity": "sha512-k/n0McAu8PvonfQRLyKKUvvdb+Gh/O5iAeIwv535Hpxw9B1qZcrYdZyWtHZ8O5PkA9/b/Kk+BdvtgcxeKMB/2g==", + "requires": { + "@hapi/hoek": "9.x.x", + "@hapi/joi": "17.x.x", + "@hapi/teamwork": "4.x.x" + } + }, + "@hapi/teamwork": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@hapi/teamwork/-/teamwork-4.0.0.tgz", + "integrity": "sha512-V6xYOrr5aFv/IJqNPneaYCu8vuGTKisamqHVRS3JJnbZr18TrpXdsJOYk9pjPhFti+M2YETPebQLUr820N5NoQ==" + }, + "@hapi/topo": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.0.0.tgz", + "integrity": "sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==", + "requires": { + "@hapi/hoek": "^9.0.0" + } + }, + "@mojaloop/central-services-error-handling": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-error-handling/-/central-services-error-handling-9.1.0.tgz", + "integrity": "sha512-6tljAx/3kITegnVgCxpOMGtzsrtSLRjNbcwXH1QidKtGeic1MsQIJgQIJuQcQlXGrIVDpJ/4JyOpfKCOh+AxwQ==", + "requires": { + "@mojaloop/sdk-standard-components": "8.6.9", + "lodash": "4.17.15" + } + }, + "@mojaloop/central-services-logger": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-logger/-/central-services-logger-9.1.0.tgz", + "integrity": "sha512-V45TPKI+0mqrSuQBOGH01yVotldu/6XCjsNKZ0M+82Kwhb0enQFSb4CKUr6TLjZINQfrNzQOofaSCJx8sUeSpg==", + "requires": { + "parse-strings-in-object": "2.0.0", + "rc": "1.2.8", + "winston": "3.2.1" + } + }, + "@mojaloop/central-services-metrics": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-metrics/-/central-services-metrics-9.1.0.tgz", + "integrity": "sha512-pE+zgVduOORYipJsUTa3ugm930Uzm8dnLxIkJEpBFoZWPqknDMTSZFvy2PU3g/hft2+IIuLSlOzHC7YxNdWBRA==", + "requires": { + "prom-client": "11.5.3" + } + }, + "@mojaloop/sdk-standard-components": { + "version": "8.6.9", + "resolved": "https://registry.npmjs.org/@mojaloop/sdk-standard-components/-/sdk-standard-components-8.6.9.tgz", + "integrity": "sha512-2S1pmYm8rdAlgrzUhS67+vMpKWWWxYnq2p/Hd4idrWHehSz6C4b1oxF/e4wx4SxVbFkMwgdXQt4Dy4tvoswhbQ==", + "requires": { + "base64url": "^3.0.1", + "ilp-packet": "2.2.0", + "jsonwebtoken": "^8.5.1", + "jws": "^3.2.2", + "request": "^2.34", + "request-promise-native": "^1.0.7" + } + }, + "ilp-packet": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ilp-packet/-/ilp-packet-2.2.0.tgz", + "integrity": "sha1-qHJcwmMxxuLGU1OKEGPVUBQwXjE=", + "requires": { + "bignumber.js": "^5.0.0", + "extensible-error": "^1.0.2", + "long": "^3.2.0", + "oer-utils": "^1.3.2" + } + }, + "parse-strings-in-object": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/parse-strings-in-object/-/parse-strings-in-object-2.0.0.tgz", + "integrity": "sha512-hb50xDyEo8boMtyzB1IdVE4KcTNVbIirk/ZqC8na1irOf/70DyZS30y1FIIAUe9jyHJk9s2QoZ4aBNHR9NXHsg==" } } }, "@mojaloop/event-sdk": { - "version": "8.8.1-snapshot.2", - "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-8.8.1-snapshot.2.tgz", - "integrity": "sha512-ufq+PCbASUfVA24jJ7yFKBUNVVeayop9Us8eKh05Ow5AD+JNfoulVDKPnhqDplTuRQ8Jss88u2kjPmcx9B8IXA==", + "version": "9.3.0-snapshot", + "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-9.3.0-snapshot.tgz", + "integrity": "sha512-TlC0EiFL275BXxjX8tNH+Q1txBtjs6ipCXlBE1N1dtXSDhYXDx486JN6pctUMaO68F1Ap4ubeXgbmZbAElMZcQ==", "requires": { "@grpc/proto-loader": "0.5.3", - "@mojaloop/central-services-logger": "8.6.0", - "@types/protobufjs": "6.0.0", + "@mojaloop/central-services-logger": "9.1.0", "brototype": "0.0.6", "error-callsites": "2.0.2", "grpc": "1.24.2", "lodash": "4.17.15", + "luxon": "1.22.0", "moment": "2.24.0", "parse-strings-in-object": "2.0.0", "protobufjs": "6.8.8", "rc": "1.2.8", "serialize-error": "4.1.0", - "sinon": "8.0.4", + "sinon": "9.0.0", "traceparent": "1.0.0", - "tslib": "1.10.0", + "tslib": "1.11.1", "uuid4": "1.1.4", "winston": "3.2.1" }, "dependencies": { + "@mojaloop/central-services-logger": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-logger/-/central-services-logger-9.1.0.tgz", + "integrity": "sha512-V45TPKI+0mqrSuQBOGH01yVotldu/6XCjsNKZ0M+82Kwhb0enQFSb4CKUr6TLjZINQfrNzQOofaSCJx8sUeSpg==", + "requires": { + "parse-strings-in-object": "2.0.0", + "rc": "1.2.8", + "winston": "3.2.1" + } + }, "parse-strings-in-object": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/parse-strings-in-object/-/parse-strings-in-object-2.0.0.tgz", "integrity": "sha512-hb50xDyEo8boMtyzB1IdVE4KcTNVbIirk/ZqC8na1irOf/70DyZS30y1FIIAUe9jyHJk9s2QoZ4aBNHR9NXHsg==" + }, + "tslib": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", + "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==" } } }, @@ -845,26 +981,34 @@ "dev": true }, "@sinonjs/commons": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.0.tgz", - "integrity": "sha512-qbk9AP+cZUsKdW1GJsBpxPKFmCJ0T8swwzVje3qFd+AkQb74Q/tiuzrdfFg8AD2g5HH/XbE/I8Uc1KYHVYWfhg==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.1.tgz", + "integrity": "sha512-Debi3Baff1Qu1Unc3mjJ96MgpbwTn43S1+9yJ0llWygPwDNu2aaWBD6yc9y/Z8XDRNhx7U+u2UDg2OGQXkclUQ==", "requires": { "type-detect": "4.0.8" } }, + "@sinonjs/fake-timers": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.0.tgz", + "integrity": "sha512-atR1J/jRXvQAb47gfzSK8zavXy7BcpnYq21ALon0U99etu99vsir0trzIO3wpeLtW+LLVY6X7EkfVTbjGSH8Ww==", + "requires": { + "@sinonjs/commons": "^1.7.0" + } + }, "@sinonjs/formatio": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-4.0.1.tgz", - "integrity": "sha512-asIdlLFrla/WZybhm0C8eEzaDNNrzymiTqHMeJl6zPW2881l3uuVRpm0QlRQEjqYWv6CcKMGYME3LbrLJsORBw==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-5.0.1.tgz", + "integrity": "sha512-KaiQ5pBf1MpS09MuA0kp6KBQt2JUOQycqVG1NZXvzeaXe5LGFqAKueIS0bw4w0P9r7KuBSVdUk5QjXsUdu2CxQ==", "requires": { "@sinonjs/commons": "^1", - "@sinonjs/samsam": "^4.2.0" + "@sinonjs/samsam": "^5.0.2" } }, "@sinonjs/samsam": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-4.2.2.tgz", - "integrity": "sha512-z9o4LZUzSD9Hl22zV38aXNykgFeVj8acqfFabCY6FY83n/6s/XwNJyYYldz6/9lBJanpno9h+oL6HTISkviweA==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.3.tgz", + "integrity": "sha512-QucHkc2uMJ0pFGjJUDP3F9dq5dx8QIaqISl9QgwLOh6P9yv877uONPGXh/OH/0zmM3tW1JjuJltAZV2l7zU+uQ==", "requires": { "@sinonjs/commons": "^1.6.0", "lodash.get": "^4.4.2", @@ -906,17 +1050,9 @@ "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==" }, "@types/node": { - "version": "10.17.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.13.tgz", - "integrity": "sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg==" - }, - "@types/protobufjs": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@types/protobufjs/-/protobufjs-6.0.0.tgz", - "integrity": "sha512-A27RDExpAf3rdDjIrHKiJK6x8kqqJ4CmoChwtipfhVAn1p7+wviQFFP7dppn8FslSbHtQeVPvi8wNKkDjSYjHw==", - "requires": { - "protobufjs": "*" - } + "version": "10.17.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.17.tgz", + "integrity": "sha512-gpNnRnZP3VWzzj5k3qrpRC6Rk3H/uclhAVo1aIvwzK5p5cOrs9yEyQ8H/HBsBY0u5rrWxXEiVPQ0dEB6pkjE8Q==" }, "abab": { "version": "2.0.3", @@ -4015,9 +4151,9 @@ } }, "just-extend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", - "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", + "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==" }, "jwa": { "version": "1.4.1", @@ -4243,14 +4379,6 @@ "triple-beam": "^1.3.0" } }, - "lolex": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-5.1.2.tgz", - "integrity": "sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A==", - "requires": { - "@sinonjs/commons": "^1.7.0" - } - }, "long": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", @@ -4280,6 +4408,11 @@ "yallist": "^2.1.2" } }, + "luxon": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.22.0.tgz", + "integrity": "sha512-3sLvlfbFo+AxVEY3IqxymbumtnlgBwjDExxK60W3d+trrUzErNAz/PfvPT+mva+vEUrdIodeCOs7fB6zHtRSrw==" + }, "make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", @@ -4596,15 +4729,14 @@ "dev": true }, "nise": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/nise/-/nise-3.0.1.tgz", - "integrity": "sha512-fYcH9y0drBGSoi88kvhpbZEsenX58Yr+wOJ4/Mi1K4cy+iGP/a73gNoyNhu5E9QxPdgTlVChfIaAlnyOy/gHUA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.3.tgz", + "integrity": "sha512-EGlhjm7/4KvmmE6B/UFsKh7eHykRl9VH+au8dduHLCyWUO/hr7+N+WtTvDUwc9zHuM1IaIJs/0lQ6Ag1jDkQSg==", "requires": { "@sinonjs/commons": "^1.7.0", - "@sinonjs/formatio": "^4.0.1", + "@sinonjs/fake-timers": "^6.0.0", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", - "lolex": "^5.0.1", "path-to-regexp": "^1.7.0" } }, @@ -5984,16 +6116,16 @@ } }, "sinon": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-8.0.4.tgz", - "integrity": "sha512-cFsmgmvsgFb87e7SV7IcekogITlHX2KmlplyI9Pda0FH1Z8Ms/kWbpLs25Idp0m6ZJ3HEEjhaYYXbcTtWWUn4w==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.0.tgz", + "integrity": "sha512-c4bREcvuK5VuEGyMW/Oim9I3Rq49Vzb0aMdxouFaA44QCFpilc5LJOugrX+mkrvikbqCimxuK+4cnHVNnLR41g==", "requires": { "@sinonjs/commons": "^1.7.0", - "@sinonjs/formatio": "^4.0.1", - "@sinonjs/samsam": "^4.2.1", - "diff": "^4.0.1", - "lolex": "^5.1.2", - "nise": "^3.0.1", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/formatio": "^5.0.0", + "@sinonjs/samsam": "^5.0.1", + "diff": "^4.0.2", + "nise": "^4.0.1", "supports-color": "^7.1.0" }, "dependencies": { @@ -6482,9 +6614,9 @@ } }, "tr46": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.0.tgz", - "integrity": "sha512-LrErSqfhdUw73AC/eXV2fEmNkvgSYxfm5lvxnLvuVgoVDknvD28Pa5FeDGc8RuVouDxUD3GnHHFv7xnBp7As5w==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.2.tgz", + "integrity": "sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==", "requires": { "punycode": "^2.1.1" } @@ -6505,7 +6637,8 @@ "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true }, "tunnel-agent": { "version": "0.6.0", diff --git a/package.json b/package.json index 9d9a5ce5..196df7f8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@mojaloop/central-services-error-handling": "8.7.0", "@mojaloop/central-services-logger": "8.6.0", "@mojaloop/central-services-metrics": "8.8.0", - "@mojaloop/central-services-shared": "8.8.3", + "@mojaloop/central-services-shared": "9.3.2-snapshot", "axios": "0.19.2", "base64url": "3.0.1", "blipp": "4.0.1", From ddd6a2e27137046f3d4ae25914d99ca863e4f621 Mon Sep 17 00:00:00 2001 From: Miguel de Barros Date: Mon, 30 Mar 2020 18:52:46 +0200 Subject: [PATCH 22/25] Added support for configuring the HTTP Agent options for callbacks. --- package-lock.json | 2 +- package.json | 2 +- src/index.js | 7 ++- src/lib/sendRequest.js | 107 ++++++++++++++++++++++++++++++++++++++--- 4 files changed, 107 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50a7d0db..778d7848 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "9.3.2-snapshot.1", + "version": "9.4.0-perf1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 25e76ca3..533af896 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sims", - "version": "9.3.2-snapshot.1", + "version": "9.4.0-perf1.0", "description": "A super-simple fsp simulator", "main": "src/index.js", "author": "ModusBox", diff --git a/src/index.js b/src/index.js index 01a58cc9..3b2554c5 100644 --- a/src/index.js +++ b/src/index.js @@ -26,9 +26,14 @@ const Routes = require('./routes') const Setup = require('.' + '/shared/setup') process.env.UV_THREADPOOL_SIZE = 12 +let httpHostPort = process.env.HTTP_HOST_PORT || 8444 + +if (httpHostPort && !isNaN(httpHostPort)) { + httpHostPort = parseInt(httpHostPort) +} module.exports = Setup.initialize({ service: 'api', - port: 8444, + port: httpHostPort, modules: [Routes] }) diff --git a/src/lib/sendRequest.js b/src/lib/sendRequest.js index 3392aa5d..168cd743 100644 --- a/src/lib/sendRequest.js +++ b/src/lib/sendRequest.js @@ -29,13 +29,104 @@ const Logger = require('@mojaloop/central-services-logger') const request = require('axios') const { pickBy, identity } = require('lodash') -module.exports = async (url, opts, span) => { - Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) - let optionsWithCleanHeaders = Object.assign({}, opts, { headers: pickBy(opts.headers, identity) }) - if (span) { - optionsWithCleanHeaders = span.injectContextToHttpRequest(optionsWithCleanHeaders) +// module.exports = async (url, opts, span) => { +// Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) +// let optionsWithCleanHeaders = Object.assign({}, opts, { headers: pickBy(opts.headers, identity) }) +// if (span) { +// optionsWithCleanHeaders = span.injectContextToHttpRequest(optionsWithCleanHeaders) +// } +// const res = await request(url, optionsWithCleanHeaders) +// Logger.info((new Date().toISOString()), 'response: ', res.status) +// return res +// } + +const httpKeepAlive = process.env.HTTP_KEEPALIVE || 'true' +const httpKeepAliveMsecs = process.env.HTTP_KEEPALIVEMS || undefined +const httpMaxSockets = process.env.HTTP_MAXSOCKETS || undefined +const httpMaxFreeSockets = process.env.HTTP_MAXFREESOCKETS || undefined +const httpTimeoutMsecs = process.env.HTTP_TIMEOUTMS || undefined + +const httpAgentConfig = {} + +if (httpKeepAlive && httpKeepAlive === 'true') { + Object.assign(httpAgentConfig, { keepAlive: true }) +} + +if (httpKeepAliveMsecs && !isNaN(httpKeepAliveMsecs)) { + Object.assign(httpAgentConfig, { keepAliveMsecs: parseInt(httpKeepAliveMsecs) }) +} + +if (httpMaxSockets && !isNaN(httpMaxSockets)) { + Object.assign(httpAgentConfig, { maxSockets: parseInt(httpMaxSockets) }) +} + +if (httpMaxFreeSockets && !isNaN(httpMaxFreeSockets)) { + Object.assign(httpAgentConfig, { maxFreeSockets: parseInt(httpMaxFreeSockets) }) +} + +if (httpTimeoutMsecs && !isNaN(httpTimeoutMsecs)) { + Object.assign(httpAgentConfig, { timeout: parseInt(httpTimeoutMsecs) }) +} + + +/** + * Class: HTTPRequestHandler + * Implementation that allows config options to be injected into underying Axios. + * See https://github.com/axios/axios#request-config for configuration options. + * TODO: + * - Productionise code below, and also create unit tests, etc. + * - Consider replacing all sendRequest using the implementation below +*/ + +const http = require('http') +const axios = require('axios') +class HTTPRequestHandler { + constructor(opts) { + if (opts) { + this._opts = opts + } else { + // Set config defaults when creating the instance + this._opts = { + httpAgent: new http.Agent({ + "keepAlive": true + }) + } + } + + this._requestInstance = axios.create(opts) } - const res = await request(url, optionsWithCleanHeaders) - Logger.info((new Date().toISOString()), 'response: ', res.status) - return res + + /** + * @method sendRequest + * + * @description sends a request to url + * + * @param {string} url the endpoint for the service you require + * @param {object} opts option config for axios - https://github.com/axios/axios#request-config + * @param {object} span a span for event logging if this request is within a span + * + *@return {object} The response for the request being sent or error object with response included + */ + sendRequest = async (url, opts, span) => { + Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) + let optionsWithCleanHeaders = Object.assign({}, opts, { headers: pickBy(opts.headers, identity) }) + if (span) { + optionsWithCleanHeaders = span.injectContextToHttpRequest(optionsWithCleanHeaders) + } + const res = await this._requestInstance.request(url, optionsWithCleanHeaders) + Logger.info((new Date().toISOString()), 'response: ', res.status) + return res + } +} + +const httpRequestHandler = new HTTPRequestHandler({ + httpAgent: new http.Agent( + { + httpAgent: httpAgentConfig + } + ) +}) + +module.exports = async (url, opts, span) => { + return await httpRequestHandler.sendRequest(url, optionsWithCleanHeaders) } From 94069607c97669de3af52dafbd018d3dffeccc80 Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 14 Apr 2020 10:43:13 +0300 Subject: [PATCH 23/25] ignored some vulnerability checks for a week --- audit-resolve.json | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/audit-resolve.json b/audit-resolve.json index d8776842..2cfccba0 100644 --- a/audit-resolve.json +++ b/audit-resolve.json @@ -2,43 +2,43 @@ "decisions": { "1179|@mojaloop/central-services-logger>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|@mojaloop/central-services-shared>@mojaloop/central-services-logger>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|@mojaloop/central-services-shared>@mojaloop/event-sdk>@mojaloop/central-services-logger>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|@mojaloop/central-services-shared>@mojaloop/event-sdk>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|npm-check-updates>requireg>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|npm-check-updates>update-notifier>latest-version>package-json>registry-auth-token>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|npm-check-updates>update-notifier>latest-version>package-json>registry-url>rc>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|standard>standard-engine>minimist": { "decision": "ignore", - "madeAt": 1585126050129, - "expiresAt": 1585730841159 + "madeAt": 1586850165517, + "expiresAt": 1587454961179 }, "1179|npm-check-updates>rc-config-loader>json5>minimist": { "decision": "ignore", @@ -47,23 +47,23 @@ }, "1179|@mojaloop/central-services-shared>@mojaloop/event-sdk>grpc>node-pre-gyp>mkdirp>minimist": { "decision": "ignore", - "madeAt": 1585126057838, - "expiresAt": 1585730841159 + "madeAt": 1586850170432, + "expiresAt": 1587454961179 }, "1179|@mojaloop/central-services-shared>@mojaloop/event-sdk>grpc>node-pre-gyp>tar>mkdirp>minimist": { "decision": "ignore", - "madeAt": 1585126057838, - "expiresAt": 1585730841159 + "madeAt": 1586850170432, + "expiresAt": 1587454961179 }, "1179|@mojaloop/central-services-shared>@mojaloop/event-sdk>grpc>node-pre-gyp>rc>minimist": { "decision": "ignore", - "madeAt": 1585126057838, - "expiresAt": 1585730841159 + "madeAt": 1586850170432, + "expiresAt": 1587454961179 }, "1179|hapi-swagger>handlebars>optimist>minimist": { "decision": "ignore", - "madeAt": 1585126057838, - "expiresAt": 1585730841159 + "madeAt": 1586850167997, + "expiresAt": 1587454961179 }, "1179|standard>eslint>file-entry-cache>flat-cache>write>mkdirp>minimist": { "decision": "ignore", From 452feab16eb350d77d2fbd2af95a26b10e71ca23 Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 14 Apr 2020 12:13:36 +0300 Subject: [PATCH 24/25] removed threadpool size setting from code and changed logger level for perf --- src/index.js | 1 - src/payee/handler.js | 4 ++-- src/payer/handler.js | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 3b2554c5..75fed98d 100644 --- a/src/index.js +++ b/src/index.js @@ -25,7 +25,6 @@ const Routes = require('./routes') const Setup = require('.' + '/shared/setup') -process.env.UV_THREADPOOL_SIZE = 12 let httpHostPort = process.env.HTTP_HOST_PORT || 8444 if (httpHostPort && !isNaN(httpHostPort)) { diff --git a/src/payee/handler.js b/src/payee/handler.js index e2498321..0cc45343 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -308,7 +308,7 @@ exports.postTransfers = async function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.error(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) + Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) Logger.debug(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${request.method} ${request.path} ${request.payload.transferId}` @@ -376,7 +376,7 @@ exports.postTransfers = async function (request, h) { } }) - Logger.error(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) + Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, diff --git a/src/payer/handler.js b/src/payer/handler.js index 0425fe1c..918447af 100644 --- a/src/payer/handler.js +++ b/src/payer/handler.js @@ -162,7 +162,7 @@ exports.putTransfersById = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.error(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) + Logger.perf(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) @@ -179,7 +179,7 @@ exports.putTransfersById = function (request, h) { // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) - Logger.error(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) + Logger.perf(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } From 44e9de6d2c543903a3b7e1c7b60a1531ac23d16c Mon Sep 17 00:00:00 2001 From: Valentin Date: Wed, 15 Apr 2020 06:52:52 +0300 Subject: [PATCH 25/25] updated logger to use Logger.is{Level}Enabled --- src/acceptheaderpayee/handler.js | 42 ++++++------- src/bulkTransfers/handler.js | 38 ++++++------ src/lib/metrics.js | 2 +- src/lib/requestLogger.js | 20 +++--- src/lib/sendRequest.js | 8 +-- src/noresponsepayeefsp/handler.js | 16 ++--- src/oracle/handler.js | 10 +-- src/payee/handler.js | 98 +++++++++++++++--------------- src/payer/handler.js | 44 +++++++------- src/routes.js | 2 +- src/shared/setup.js | 10 +-- src/testfsp1/handler.js | 82 ++++++++++++------------- src/testfsp2/handler.js | 82 ++++++++++++------------- src/testfsp3/handler.js | 82 ++++++++++++------------- src/testfsp4/handler.js | 82 ++++++++++++------------- src/transactionRequests/handler.js | 24 ++++---- 16 files changed, 321 insertions(+), 321 deletions(-) diff --git a/src/acceptheaderpayee/handler.js b/src/acceptheaderpayee/handler.js index 6c1dfebe..15b54bc6 100644 --- a/src/acceptheaderpayee/handler.js +++ b/src/acceptheaderpayee/handler.js @@ -68,7 +68,7 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -90,7 +90,7 @@ exports.postPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info('IN PAYEEFSP:: POST /acceptheaderpayeefsp/parties/' + request.params.id, request.payload) + Logger.isInfoEnabled && Logger.info('IN PAYEEFSP:: POST /acceptheaderpayeefsp/parties/' + request.params.id, request.payload) correlationCache.set(request.params.id, request.payload) histTimerEnd({ success: true, fsp: 'payee', operation: 'postPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) @@ -106,7 +106,7 @@ exports.getPartiesByTypeAndId = function (req, h) { ).startTimer() const metadata = `${req.method} ${req.path} ${req.params.id} ` - Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) // Saving Incoming request const incomingRequest = { headers: req.headers @@ -146,9 +146,9 @@ exports.getPartiesByTypeAndId = function (req, h) { data: JSON.stringify(correlationCache.get(req.params.id)) } - // Logger.info((new Date().toISOString()), 'Executing PUT', url) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'Executing PUT', url) const res = await request(url, opts, req.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) @@ -156,7 +156,7 @@ exports.getPartiesByTypeAndId = function (req, h) { histTimerEnd({ success: true, fsp: 'payee', operation: 'getPartiesByTypeAndId', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) histTimerEnd({ success: false, fsp: 'payee', operation: 'getPartiesByTypeAndId', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } })() @@ -174,8 +174,8 @@ exports.postQuotes = function (req, h) { const metadata = `${req.method} ${req.path}` const quotesRequest = req.payload - Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) - Logger.info(`incoming request: ${quotesRequest.quoteId}`) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info(`incoming request: ${quotesRequest.quoteId}`) // Saving Incoming request const incomingRequest = { @@ -234,9 +234,9 @@ exports.postQuotes = function (req, h) { }), data: JSON.stringify(quotesResponse) } - // Logger.info((new Date().toISOString()), 'Executing PUT', url) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'Executing PUT', url) const res = await request(url, opts, req.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) @@ -244,7 +244,7 @@ exports.postQuotes = function (req, h) { histTimerEnd({ success: true, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) histTimerEnd({ success: false, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) // TODO: what if this fails? We need to log. What happens by default? // const url = await rq.createErrorUrl(db, req.path, requesterName); @@ -265,10 +265,10 @@ exports.postTransfers = async function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isDebugEnabled && Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${req.method} ${req.path} ${req.payload.transferId}` - Logger.info(`IN PAYEEFSP:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -317,9 +317,9 @@ exports.postTransfers = async function (req, h) { data: JSON.stringify(transfersResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) @@ -332,7 +332,7 @@ exports.postTransfers = async function (req, h) { destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) histTimerEnd({ success: false, fsp: 'payee', @@ -368,7 +368,7 @@ exports.putTransfersById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) @@ -390,7 +390,7 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -411,7 +411,7 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN PAYEEFSP:: Final response for GET /acceptheaderpayeefsp/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: Final response for GET /acceptheaderpayeefsp/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}`) histTimerEnd({ success: true, fsp: 'payee', operation: 'getcorrelationId' }) return h.response(correlationCache.get(request.params.id)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) @@ -424,7 +424,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -440,7 +440,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /acceptheaderpayeefsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/bulkTransfers/handler.js b/src/bulkTransfers/handler.js index bbd830b3..18415f39 100644 --- a/src/bulkTransfers/handler.js +++ b/src/bulkTransfers/handler.js @@ -45,10 +45,10 @@ exports.postBulkTransfers = async function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`[cid=${req.payload.bulkTransferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isDebugEnabled && Logger.debug(`[cid=${req.payload.bulkTransferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${req.method} ${req.path} ${req.payload.bulkTransferId}` - Logger.info(`IN Bulk Transfers POST:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN Bulk Transfers POST:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -109,14 +109,14 @@ exports.postBulkTransfers = async function (req, h) { }), data: JSON.stringify(bulkTransferResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(bulkTransferResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(bulkTransferResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: req.headers['fspiop-source'], @@ -125,8 +125,8 @@ exports.postBulkTransfers = async function (req, h) { destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) histTimerEnd({ success: false, fsp: req.headers['fspiop-source'], @@ -143,7 +143,7 @@ exports.postBulkTransfers = async function (req, h) { // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); } } else { - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: req.headers['fspiop-source'], @@ -162,9 +162,9 @@ exports.putBulkTransfersById = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - START`) - Logger.info(`IN Bulk Transfer:: PUT /bulkTransfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN Bulk Transfer:: PUT /bulkTransfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) @@ -175,7 +175,7 @@ exports.putBulkTransfersById = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - END`) histTimerEnd({ success: true, fsp: request.headers['fspiop-source'], @@ -193,9 +193,9 @@ exports.putBulkTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - START`) - Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -205,7 +205,7 @@ exports.putBulkTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: request.headers['fspiop-source'], @@ -223,11 +223,11 @@ exports.getCorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - START`) - Logger.info(`IN bulk transfers:: Final response for GET /bulkTransfers/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}`) + Logger.isInfoEnabled && Logger.info(`IN bulk transfers:: Final response for GET /bulkTransfers/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'getBulkCorrelationId' }) return h.response(correlationCache.get(request.params.id)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -239,7 +239,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -255,7 +255,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN Bulk Transfers :: PUT /bulkTransfers/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/lib/metrics.js b/src/lib/metrics.js index 1c83ff32..5f81b7e1 100644 --- a/src/lib/metrics.js +++ b/src/lib/metrics.js @@ -50,7 +50,7 @@ const metricOptions = { const setup = () => { if (alreadySetup || isDisabled) { if (isDisabled) { - Logger.warn(disabledMessage) + Logger.isWarnEnabled && Logger.warn(disabledMessage) } return } diff --git a/src/lib/requestLogger.js b/src/lib/requestLogger.js index fe9ed624..4e35b04a 100644 --- a/src/lib/requestLogger.js +++ b/src/lib/requestLogger.js @@ -6,16 +6,16 @@ const Util = require('util') const logRequest = function (request) { const traceId = request.headers.traceparent ? request.headers.traceparent.split('-')[1] : undefined if (request.path.indexOf('health') > -1 || request.path.indexOf('metrics') > -1) { - Logger.debug(`L1p-Trace-Id=${traceId} - Method: ${request.method} Path: ${request.path} Query: ${JSON.stringify(request.query)}`) - Logger.debug(`L1p-Trace-Id=${traceId} - Headers: ${JSON.stringify(request.headers)}`) + Logger.isDebugEnabled && Logger.debug(`L1p-Trace-Id=${traceId} - Method: ${request.method} Path: ${request.path} Query: ${JSON.stringify(request.query)}`) + Logger.isDebugEnabled && Logger.debug(`L1p-Trace-Id=${traceId} - Headers: ${JSON.stringify(request.headers)}`) if (request.body) { - Logger.debug(`L1p-Trace-Id=${traceId} - Body: ${request.body}`) + Logger.isDebugEnabled && Logger.debug(`L1p-Trace-Id=${traceId} - Body: ${request.body}`) } } else { - Logger.info(`L1p-Trace-Id=${traceId} - Method: ${request.method} Path: ${request.path} Query: ${JSON.stringify(request.query)}`) - Logger.info(`L1p-Trace-Id=${traceId} - Headers: ${JSON.stringify(request.headers)}`) + Logger.isInfoEnabled && Logger.info(`L1p-Trace-Id=${traceId} - Method: ${request.method} Path: ${request.path} Query: ${JSON.stringify(request.query)}`) + Logger.isInfoEnabled && Logger.info(`L1p-Trace-Id=${traceId} - Headers: ${JSON.stringify(request.headers)}`) if (request.body) { - Logger.info(`L1p-Trace-Id=${traceId} - Body: ${request.body}`) + Logger.isInfoEnabled && Logger.info(`L1p-Trace-Id=${traceId} - Body: ${request.body}`) } } } @@ -31,15 +31,15 @@ const logResponse = function (request) { } if (request.path.indexOf('health') > -1 || request.path.indexOf('metrics') > -1) { if (!response) { - Logger.debug(`L1p-Trace-Id=${traceId} - Response: ${request.response}`) + Logger.isDebugEnabled && Logger.debug(`L1p-Trace-Id=${traceId} - Response: ${request.response}`) } else { - Logger.debug(`L1p-Trace-Id=${traceId} - Response: ${response} Status: ${request.response.statusCode}`) + Logger.isDebugEnabled && Logger.debug(`L1p-Trace-Id=${traceId} - Response: ${response} Status: ${request.response.statusCode}`) } } else { if (!response) { - Logger.info(`L1p-Trace-Id=${traceId} - Response: ${request.response}`) + Logger.isInfoEnabled && Logger.info(`L1p-Trace-Id=${traceId} - Response: ${request.response}`) } else { - Logger.info(`L1p-Trace-Id=${traceId} - Response: ${response} Status: ${request.response.statusCode}`) + Logger.isInfoEnabled && Logger.info(`L1p-Trace-Id=${traceId} - Response: ${response} Status: ${request.response.statusCode}`) } } } diff --git a/src/lib/sendRequest.js b/src/lib/sendRequest.js index e4bd1147..62967c6a 100644 --- a/src/lib/sendRequest.js +++ b/src/lib/sendRequest.js @@ -29,13 +29,13 @@ const Logger = require('@mojaloop/central-services-logger') const { pickBy, identity } = require('lodash') // module.exports = async (url, opts, span) => { -// Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) +// Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) // let optionsWithCleanHeaders = Object.assign({}, opts, { headers: pickBy(opts.headers, identity) }) // if (span) { // optionsWithCleanHeaders = span.injectContextToHttpRequest(optionsWithCleanHeaders) // } // const res = await request(url, optionsWithCleanHeaders) -// Logger.info((new Date().toISOString()), 'response: ', res.status) +// Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) // return res // } @@ -106,13 +106,13 @@ class HTTPRequestHandler { *@return {object} The response for the request being sent or error object with response included */ async sendRequest (url, opts, span) { - Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) + Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(opts.body)}]`) let optionsWithCleanHeaders = Object.assign({}, opts, { headers: pickBy(opts.headers, identity) }) if (span) { optionsWithCleanHeaders = span.injectContextToHttpRequest(optionsWithCleanHeaders) } const res = await this._requestInstance.request(url, optionsWithCleanHeaders) - Logger.info((new Date().toISOString()), 'response: ', res.status) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) return res } } diff --git a/src/noresponsepayeefsp/handler.js b/src/noresponsepayeefsp/handler.js index b1d55350..e44925ab 100644 --- a/src/noresponsepayeefsp/handler.js +++ b/src/noresponsepayeefsp/handler.js @@ -58,9 +58,9 @@ exports.putTransfersById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) - Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -71,7 +71,7 @@ exports.putTransfersById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -83,9 +83,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) - Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -95,7 +95,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -107,7 +107,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -123,7 +123,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN noresponsepayeefsp:: PUT /noresponsepayeefsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/oracle/handler.js b/src/oracle/handler.js index 873bd940..adba11db 100644 --- a/src/oracle/handler.js +++ b/src/oracle/handler.js @@ -38,7 +38,7 @@ exports.createParticipantsByTypeAndId = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`createParticipantByTypeId::ID=${request.params.ID} payload=${request.payload}`) + Logger.isDebugEnabled && Logger.debug(`createParticipantByTypeId::ID=${request.params.ID} payload=${request.payload}`) addNewRequest(request) const record = { partyList: [ @@ -74,7 +74,7 @@ exports.getParticipantsByTypeId = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`getParticipantsByTypeId::ID=${request.params.ID}`) + Logger.isDebugEnabled && Logger.debug(`getParticipantsByTypeId::ID=${request.params.ID}`) addNewRequest(request) let idMap = new Map() let response @@ -107,7 +107,7 @@ exports.updateParticipantsByTypeId = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`updateParticipantByTypeId::ID=${request.params.ID} payload=${request.payload}`) + Logger.isDebugEnabled && Logger.debug(`updateParticipantByTypeId::ID=${request.params.ID} payload=${request.payload}`) addNewRequest(request) let idMap if (participantCache.get(request.params.Type)) { @@ -141,7 +141,7 @@ exports.delParticipantsByTypeId = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`delParticipantsByTypeId::ID=${request.params.ID}`) + Logger.isDebugEnabled && Logger.debug(`delParticipantsByTypeId::ID=${request.params.ID}`) addNewRequest(request) let idMap if (participantCache.get(request.params.Type)) { @@ -245,7 +245,7 @@ exports.getPartiesByTypeIdAndSubId = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`getPartiesByTypeId::ID=${request.params.ID}`) + Logger.isDebugEnabled && Logger.debug(`getPartiesByTypeId::ID=${request.params.ID}`) addNewRequest(request) let idMap = new Map() let response diff --git a/src/payee/handler.js b/src/payee/handler.js index 0cc45343..32bb1a8b 100644 --- a/src/payee/handler.js +++ b/src/payee/handler.js @@ -71,9 +71,9 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) - Logger.info(`IN PAYEEFSP:: PUT /payeefsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /payeefsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -84,7 +84,7 @@ exports.putParticipantsByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -96,12 +96,12 @@ exports.postPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) - Logger.info('IN PAYEEFSP:: POST /payeefsp/parties/' + request.params.id, request.payload) + Logger.isInfoEnabled && Logger.info('IN PAYEEFSP:: POST /payeefsp/parties/' + request.params.id, request.payload) correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -114,10 +114,10 @@ exports.getPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getPartiesByTypeAndId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getPartiesByTypeAndId - START`) const metadata = `${request.method} ${request.path} ${request.params.id} ` - Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) // Saving Incoming request const incomingRequest = { headers: request.headers @@ -161,19 +161,19 @@ exports.getPartiesByTypeAndId = function (request, h) { data: JSON.stringify(correlationCache.get(request.params.id)) } - // Logger.info((new Date().toISOString()), 'Executing PUT', url) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'Executing PUT', url) const res = await sendRequest(url, opts, request.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) } - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getPartiesByTypeAndId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getPartiesByTypeAndId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'getPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getPartiesByTypeAndId - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getPartiesByTypeAndId - ERROR`) histTimerEnd({ success: false, fsp: 'payee', operation: 'getPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) } })() @@ -189,12 +189,12 @@ exports.postQuotes = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) const metadata = `${request.method} ${request.path}` const quoteRequest = request.payload - Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) - Logger.info(`incoming request: ${quoteRequest.quoteId}`) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN PAYEEFSP::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info(`incoming request: ${quoteRequest.quoteId}`) // Saving Incoming request const incomingRequest = { @@ -206,8 +206,8 @@ exports.postQuotes = function (request, h) { // prepare response // const fulfillImage = new cc.PreimageSha256() // fulfillImage.setPreimage(new Buffer('hello world')) - // Logger.info(fulfillImage.serializeUri()) - // Logger.info(fulfillImage.getConditionUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.serializeUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.getConditionUri()) // const condition = fulfillImage.getConditionUri() // // const binaryPrepare = IlpPacket.serializeIlpPrepare({ @@ -276,19 +276,19 @@ exports.postQuotes = function (request, h) { }), data: JSON.stringify(quotesResponse) } - // Logger.info((new Date().toISOString()), 'Executing PUT', url) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'Executing PUT', url) const res = await sendRequest(url, opts, request.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) } - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postQuotes', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) histTimerEnd({ success: false, fsp: 'payee', operation: 'postQuotes', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) // TODO: what if this fails? We need to log. What happens by default? // const url = await rq.createErrorUrl(db, request.path, requesterName); @@ -308,11 +308,11 @@ exports.postTransfers = async function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) - Logger.debug(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - START`) + Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${request.method} ${request.path} ${request.payload.transferId}` - Logger.info(`IN PAYEEFSP:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -366,18 +366,18 @@ exports.postTransfers = async function (request, h) { data: JSON.stringify(transfersResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) setImmediate(async () => { const res = await sendRequest(url, opts, request.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if ((res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) && (res.status !== Enums.Http.ReturnCodes.OK.CODE)) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } }) - Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::postTransfers - END`) + Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -386,8 +386,8 @@ exports.postTransfers = async function (request, h) { destination: request.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) histTimerEnd({ success: false, fsp: 'payee', @@ -404,7 +404,7 @@ exports.postTransfers = async function (request, h) { // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); } } else { - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -423,9 +423,9 @@ exports.putTransfersById = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - START`) - Logger.info(`IN PAYEEFSP:: PUT /payeefsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /payeefsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) @@ -436,7 +436,7 @@ exports.putTransfersById = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -448,9 +448,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - START`) - Logger.info(`IN PAYEEFSP:: PUT /payeefsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /payeefsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -460,7 +460,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -472,19 +472,19 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - START`) const responseData = correlationCache.get(request.params.id) - Logger.info(`IN PAYEEFSP:: Final response for GET /payeefsp/correlationid/${request.params.id}, CACHE: [${JSON.stringify(responseData)}`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: Final response for GET /payeefsp/correlationid/${request.params.id}, CACHE: [${JSON.stringify(responseData)}`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'getcorrelationId' }) return h.response(responseData).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } exports.getQuotesById = function (request, h) { const responseData = quoteCache.get(request.params.id) - Logger.info(`IN PAYEEFSP:: PUT callback for GET /payeefsp/quotes/${request.params.id}, CACHE: [${JSON.stringify(responseData)}`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT callback for GET /payeefsp/quotes/${request.params.id}, CACHE: [${JSON.stringify(responseData)}`) quoteCache.del(request.params.id) if (responseData) { @@ -531,7 +531,7 @@ exports.getQuotesById = function (request, h) { }), data: JSON.stringify(responseData) } - // Logger.info((new Date().toISOString()), 'Executing PUT', url) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'Executing PUT', url) const res = await sendRequest(url, opts, request.span) if (res.status !== Enums.Http.ReturnCodes.OK.CODE) { throw new Error(`Failed to send. Result: ${res}`) @@ -539,13 +539,13 @@ exports.getQuotesById = function (request, h) { histTimerEnd({ success: true, fsp: 'payee', operation: 'getQuotes', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) histTimerEnd({ success: false, fsp: 'payee', operation: 'getQuotes', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) } }) } else { setImmediate(async () => { - Logger.error(`getQuotesById: Quote ${request.params.id} not found.`) + Logger.isErrorEnabled && Logger.error(`getQuotesById: Quote ${request.params.id} not found.`) await sendErrorCallback( ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.QUOTE_ID_NOT_FOUND, `Quote id ${request.params.id} not found`, null, request.headers['fspiop-source']), request.params.id, @@ -606,7 +606,7 @@ const sendErrorCallback = async (fspiopError, quoteId, headers, span) => { histTimerEnd({ success: true, fsp: 'payee', operation: 'sendErrorCallback', source: headers['fspiop-source'], destination: 'switch' }) } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) histTimerEnd({ success: false, fsp: 'payee', operation: 'sendErrorCallback', source: headers['fspiop-source'], destination: 'switch' }) } } @@ -619,7 +619,7 @@ exports.getRequestById = function (request, h) { ).startTimer() const responseData = requestCache.get(request.params.id) - Logger.info(`IN PAYEEFSP:: PUT /payeefsp/requests/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /payeefsp/requests/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) requestCache.del(request.params.id) histTimerEnd({ success: true, fsp: 'payee', operation: 'getRequestById' }) @@ -635,7 +635,7 @@ exports.getCallbackById = function (request, h) { ).startTimer() const responseData = callbackCache.get(request.params.id) - Logger.info(`IN PAYEEFSP:: PUT /payeefsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYEEFSP:: PUT /payeefsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) callbackCache.del(request.params.id) histTimerEnd({ success: true, fsp: 'payee', operation: 'getCallbackById' }) diff --git a/src/payer/handler.js b/src/payer/handler.js index 918447af..4fbae30b 100644 --- a/src/payer/handler.js +++ b/src/payer/handler.js @@ -58,9 +58,9 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -71,7 +71,7 @@ exports.putParticipantsByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -84,9 +84,9 @@ exports.putPartiesByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/parties/${request.params.type}/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/parties/${request.params.type}/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -97,7 +97,7 @@ exports.putPartiesByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putPartiesByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -124,9 +124,9 @@ exports.putQuotesById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -136,7 +136,7 @@ exports.putQuotesById = function (request, h) { callbackCache.set(request.params.id, incomingRequest) correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putQuotesById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -162,11 +162,11 @@ exports.putTransfersById = function (request, h) { 'Histogram for Simulator http operations', ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.perf(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) + Logger.isPerfEnabled && Logger.perf(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - START`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -177,9 +177,9 @@ exports.putTransfersById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) - Logger.perf(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) + Logger.isPerfEnabled && Logger.perf(`[cid=${request.params.id}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::putTransfersById - END`) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -190,9 +190,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -202,7 +202,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -214,12 +214,12 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) const responseData = correlationCache.get(request.params.id) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/correlationid/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/correlationid/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'getcorrelationId' }) return h.response(responseData).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -232,7 +232,7 @@ exports.getRequestById = function (request, h) { ).startTimer() const responseData = requestCache.get(request.params.id) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/requests/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/requests/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) requestCache.del(request.params.id) histTimerEnd({ success: true, fsp: 'payer', operation: 'getRequestById' }) @@ -248,7 +248,7 @@ exports.getCallbackById = function (request, h) { ).startTimer() const responseData = callbackCache.get(request.params.id) - Logger.info(`IN PAYERFSP:: PUT /payerfsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) + Logger.isInfoEnabled && Logger.info(`IN PAYERFSP:: PUT /payerfsp/callbacks/${request.params.id}, CACHE: [${JSON.stringify(responseData)}]`) callbackCache.del(request.params.id) histTimerEnd({ success: true, fsp: 'payer', operation: 'getCallbackById' }) diff --git a/src/routes.js b/src/routes.js index 0b247bf8..44844551 100644 --- a/src/routes.js +++ b/src/routes.js @@ -30,7 +30,7 @@ exports.plugin = { register: function (server) { Glob.sync('*/routes.js', { cwd: __dirname, ignore: 'routes.js' }) .forEach(x => { - Logger.info(`Loading module: [${x}]`) + Logger.isInfoEnabled && Logger.info(`Loading module: [${x}]`) server.route(require('./' + x)) }) } diff --git a/src/shared/setup.js b/src/shared/setup.js index 8d255524..4cf2ce12 100644 --- a/src/shared/setup.js +++ b/src/shared/setup.js @@ -48,19 +48,19 @@ const createServer = (port, modules) => { RequestLogger.logResponse(request) return h.continue }) - Logger.info('Registering server modules...') + Logger.isInfoEnabled && Logger.info('Registering server modules...') await server.register(modules) - Logger.info('Registering server plugins') + Logger.isInfoEnabled && Logger.info('Registering server plugins') await require('./plugins').registerPlugins(server) - Logger.info('Initializing metrics...') + Logger.isInfoEnabled && Logger.info('Initializing metrics...') Metrics.setup() - Logger.info('Server starting up...') + Logger.isInfoEnabled && Logger.info('Server starting up...') await server.start() - Logger.info(`Server running at: ${server.info.uri}`) + Logger.isInfoEnabled && Logger.info(`Server running at: ${server.info.uri}`) return server })() } diff --git a/src/testfsp1/handler.js b/src/testfsp1/handler.js index dbbed187..3b8f7cd8 100644 --- a/src/testfsp1/handler.js +++ b/src/testfsp1/handler.js @@ -70,9 +70,9 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) - Logger.info(`IN TESTFSP1:: PUT /testfsp1/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN TESTFSP1:: PUT /testfsp1/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -83,7 +83,7 @@ exports.putParticipantsByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -96,12 +96,12 @@ exports.postPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) - Logger.info('IN testfsp1:: POST /testfsp1/parties/' + request.params.id, request.payload) + Logger.isInfoEnabled && Logger.info('IN testfsp1:: POST /testfsp1/parties/' + request.params.id, request.payload) correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -152,9 +152,9 @@ exports.putPartiesByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) - Logger.info(`IN testfsp1:: PUT /testfsp1/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -165,7 +165,7 @@ exports.putPartiesByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putPartiesByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -193,12 +193,12 @@ exports.postQuotes = function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) const metadata = `${req.method} ${req.path}` const quotesRequest = req.payload - Logger.info((new Date().toISOString()), ['IN testfsp1::'], `received: ${metadata}. `) - Logger.info(`incoming request: ${quotesRequest.quoteId}`) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN testfsp1::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info(`incoming request: ${quotesRequest.quoteId}`) // Saving Incoming request const incomingRequest = { @@ -210,8 +210,8 @@ exports.postQuotes = function (req, h) { // prepare response // const fulfillImage = new cc.PreimageSha256() // fulfillImage.setPreimage(new Buffer('hello world')) - // Logger.info(fulfillImage.serializeUri()) - // Logger.info(fulfillImage.getConditionUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.serializeUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.getConditionUri()) // const condition = fulfillImage.getConditionUri() // // const binaryPrepare = IlpPacket.serializeIlpPrepare({ @@ -278,19 +278,19 @@ exports.postQuotes = function (req, h) { }), data: JSON.stringify(quotesResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) histTimerEnd({ success: false, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) // TODO: what if this fails? We need to log. What happens by default? // const url = await rq.createErrorUrl(db, req.path, requesterName); @@ -311,9 +311,9 @@ exports.putQuotesById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) - Logger.info(`IN testfsp1:: PUT /testfsp1/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -324,7 +324,7 @@ exports.putQuotesById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putQuotesById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -351,10 +351,10 @@ exports.postTransfers = async function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isDebugEnabled && Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${req.method} ${req.path} ${req.payload.transferId}` - Logger.info(`IN testfsp1:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -400,14 +400,14 @@ exports.postTransfers = async function (req, h) { }, data: JSON.stringify(transfersResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -416,8 +416,8 @@ exports.postTransfers = async function (req, h) { destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) histTimerEnd({ success: false, fsp: 'payee', @@ -434,7 +434,7 @@ exports.postTransfers = async function (req, h) { // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); } } else { - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -454,9 +454,9 @@ exports.putTransfersById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) - Logger.info(`IN testfsp1:: PUT /testfsp1/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -467,7 +467,7 @@ exports.putTransfersById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -479,9 +479,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) - Logger.info(`IN testfsp1:: PUT /testfsp1/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -491,7 +491,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -503,11 +503,11 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) - Logger.info(`IN testfsp1:: PUT /testfsp1/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'getcorrelationId' }) return h.response(correlationCache.get(request.params.id)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -519,7 +519,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp1:: PUT /testfsp1/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -535,7 +535,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp1:: PUT /testfsp1/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp1:: PUT /testfsp1/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/testfsp2/handler.js b/src/testfsp2/handler.js index 9817d21f..60a66f65 100644 --- a/src/testfsp2/handler.js +++ b/src/testfsp2/handler.js @@ -70,9 +70,9 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) - Logger.info(`IN testfsp2:: PUT /testfsp2/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -83,7 +83,7 @@ exports.putParticipantsByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -96,12 +96,12 @@ exports.postPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) - Logger.info('IN testfsp2:: POST /testfsp2/parties/' + request.params.id, request.payload) + Logger.isInfoEnabled && Logger.info('IN testfsp2:: POST /testfsp2/parties/' + request.params.id, request.payload) correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -152,9 +152,9 @@ exports.putPartiesByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) - Logger.info(`IN testfsp2:: PUT /testfsp2/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -165,7 +165,7 @@ exports.putPartiesByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putPartiesByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -193,12 +193,12 @@ exports.postQuotes = function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) const metadata = `${req.method} ${req.path}` const quotesRequest = req.payload - Logger.info((new Date().toISOString()), ['IN testfsp2::'], `received: ${metadata}. `) - Logger.info(`incoming request: ${quotesRequest.quoteId}`) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN testfsp2::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info(`incoming request: ${quotesRequest.quoteId}`) // Saving Incoming request const incomingRequest = { @@ -210,8 +210,8 @@ exports.postQuotes = function (req, h) { // prepare response // const fulfillImage = new cc.PreimageSha256() // fulfillImage.setPreimage(new Buffer('hello world')) - // Logger.info(fulfillImage.serializeUri()) - // Logger.info(fulfillImage.getConditionUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.serializeUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.getConditionUri()) // const condition = fulfillImage.getConditionUri() // // const binaryPrepare = IlpPacket.serializeIlpPrepare({ @@ -278,19 +278,19 @@ exports.postQuotes = function (req, h) { }), data: JSON.stringify(quotesResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) histTimerEnd({ success: false, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) // TODO: what if this fails? We need to log. What happens by default? // const url = await rq.createErrorUrl(db, req.path, requesterName); @@ -311,9 +311,9 @@ exports.putQuotesById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) - Logger.info(`IN testfsp2:: PUT /testfsp2/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -324,7 +324,7 @@ exports.putQuotesById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putQuotesById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -351,10 +351,10 @@ exports.postTransfers = async function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isDebugEnabled && Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${req.method} ${req.path} ${req.payload.transferId}` - Logger.info(`IN testfsp2:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -407,14 +407,14 @@ exports.postTransfers = async function (req, h) { }), data: JSON.stringify(transfersResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -423,8 +423,8 @@ exports.postTransfers = async function (req, h) { destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) histTimerEnd({ success: false, fsp: 'payee', @@ -441,7 +441,7 @@ exports.postTransfers = async function (req, h) { // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); } } else { - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -461,9 +461,9 @@ exports.putTransfersById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) - Logger.info(`IN testfsp2:: PUT /testfsp2/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -474,7 +474,7 @@ exports.putTransfersById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -486,9 +486,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) - Logger.info(`IN testfsp2:: PUT /testfsp2/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -498,7 +498,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -510,11 +510,11 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) - Logger.info(`IN testfsp2:: PUT /testfsp2/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'getcorrelationId' }) return h.response(correlationCache.get(request.params.id)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -526,7 +526,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp2:: PUT /testfsp2/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -542,7 +542,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp2:: PUT /testfsp2/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp2:: PUT /testfsp2/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/testfsp3/handler.js b/src/testfsp3/handler.js index 0947fc3e..c6920c0f 100644 --- a/src/testfsp3/handler.js +++ b/src/testfsp3/handler.js @@ -70,9 +70,9 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) - Logger.info(`IN testfsp3:: PUT /testfsp3/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -83,7 +83,7 @@ exports.putParticipantsByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -96,12 +96,12 @@ exports.postPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) - Logger.info('IN testfsp3:: POST /testfsp3/parties/' + request.params.id, request.payload) + Logger.isInfoEnabled && Logger.info('IN testfsp3:: POST /testfsp3/parties/' + request.params.id, request.payload) correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -152,9 +152,9 @@ exports.putPartiesByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) - Logger.info(`IN testfsp3:: PUT /testfsp3/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -165,7 +165,7 @@ exports.putPartiesByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putPartiesByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -193,12 +193,12 @@ exports.postQuotes = function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) const metadata = `${req.method} ${req.path}` const quotesRequest = req.payload - Logger.info((new Date().toISOString()), ['IN testfsp3::'], `received: ${metadata}. `) - Logger.info(`incoming request: ${quotesRequest.quoteId}`) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN testfsp3::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info(`incoming request: ${quotesRequest.quoteId}`) // Saving Incoming request const incomingRequest = { @@ -210,8 +210,8 @@ exports.postQuotes = function (req, h) { // prepare response // const fulfillImage = new cc.PreimageSha256() // fulfillImage.setPreimage(new Buffer('hello world')) - // Logger.info(fulfillImage.serializeUri()) - // Logger.info(fulfillImage.getConditionUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.serializeUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.getConditionUri()) // const condition = fulfillImage.getConditionUri() // // const binaryPrepare = IlpPacket.serializeIlpPrepare({ @@ -278,19 +278,19 @@ exports.postQuotes = function (req, h) { }), data: JSON.stringify(quotesResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) histTimerEnd({ success: false, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) // TODO: what if this fails? We need to log. What happens by default? // const url = await rq.createErrorUrl(db, req.path, requesterName); @@ -311,9 +311,9 @@ exports.putQuotesById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) - Logger.info(`IN testfsp3:: PUT /testfsp3/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -324,7 +324,7 @@ exports.putQuotesById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putQuotesById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -351,10 +351,10 @@ exports.postTransfers = async function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isDebugEnabled && Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${req.method} ${req.path} ${req.payload.transferId}` - Logger.info(`IN testfsp3:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -407,14 +407,14 @@ exports.postTransfers = async function (req, h) { }), data: JSON.stringify(transfersResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -423,8 +423,8 @@ exports.postTransfers = async function (req, h) { destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) histTimerEnd({ success: false, fsp: 'payee', @@ -441,7 +441,7 @@ exports.postTransfers = async function (req, h) { // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); } } else { - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -461,9 +461,9 @@ exports.putTransfersById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) - Logger.info(`IN testfsp3:: PUT /testfsp3/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -474,7 +474,7 @@ exports.putTransfersById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -486,9 +486,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) - Logger.info(`IN testfsp3:: PUT /testfsp3/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -498,7 +498,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -510,11 +510,11 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) - Logger.info(`IN testfsp3:: PUT /testfsp3/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'getcorrelationId' }) return h.response(correlationCache.get(request.params.id)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -526,7 +526,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp3:: PUT /testfsp3/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -542,7 +542,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp3:: PUT /testfsp3/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp3:: PUT /testfsp3/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/testfsp4/handler.js b/src/testfsp4/handler.js index bd686f14..13f2bf45 100644 --- a/src/testfsp4/handler.js +++ b/src/testfsp4/handler.js @@ -70,9 +70,9 @@ exports.putParticipantsByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - START`) - Logger.info(`IN testfsp4:: PUT /testfsp4/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/participants/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -83,7 +83,7 @@ exports.putParticipantsByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putParticipantsByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putParticipantsByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -96,12 +96,12 @@ exports.postPartiesByTypeAndId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - START`) - Logger.info('IN testfsp4:: POST /testfsp4/parties/' + request.params.id, request.payload) + Logger.isInfoEnabled && Logger.info('IN testfsp4:: POST /testfsp4/parties/' + request.params.id, request.payload) correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payee::postPartiesByTypeAndId - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postPartiesByTypeAndId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -152,9 +152,9 @@ exports.putPartiesByTypeId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - START`) - Logger.info(`IN testfsp4:: PUT /testfsp4/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/parties/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -165,7 +165,7 @@ exports.putPartiesByTypeId = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putPartiesByTypeId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putPartiesByTypeId', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -193,12 +193,12 @@ exports.postQuotes = function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - START`) const metadata = `${req.method} ${req.path}` const quotesRequest = req.payload - Logger.info((new Date().toISOString()), ['IN testfsp4::'], `received: ${metadata}. `) - Logger.info(`incoming request: ${quotesRequest.quoteId}`) + Logger.isInfoEnabled && Logger.info((new Date().toISOString()), ['IN testfsp4::'], `received: ${metadata}. `) + Logger.isInfoEnabled && Logger.info(`incoming request: ${quotesRequest.quoteId}`) // Saving Incoming request const incomingRequest = { @@ -210,8 +210,8 @@ exports.postQuotes = function (req, h) { // prepare response // const fulfillImage = new cc.PreimageSha256() // fulfillImage.setPreimage(new Buffer('hello world')) - // Logger.info(fulfillImage.serializeUri()) - // Logger.info(fulfillImage.getConditionUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.serializeUri()) + // Logger.isInfoEnabled && Logger.info(fulfillImage.getConditionUri()) // const condition = fulfillImage.getConditionUri() // // const binaryPrepare = IlpPacket.serializeIlpPrepare({ @@ -278,19 +278,19 @@ exports.postQuotes = function (req, h) { }), data: JSON.stringify(quotesResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(quotesResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info((new Date().toISOString()), 'response: ', res.status) + // Logger.isInfoEnabled && Logger.info((new Date().toISOString()), 'response: ', res.status) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${res}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - END`) histTimerEnd({ success: true, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postQuotes - ERROR`) histTimerEnd({ success: false, fsp: 'payee', operation: 'postQuotes', source: req.headers['fspiop-source'], destination: req.headers['fspiop-destination'] }) // TODO: what if this fails? We need to log. What happens by default? // const url = await rq.createErrorUrl(db, req.path, requesterName); @@ -311,9 +311,9 @@ exports.putQuotesById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - START`) - Logger.info(`IN testfsp4:: PUT /testfsp4/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/quotes/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -324,7 +324,7 @@ exports.putQuotesById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putQuotesById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putQuotesById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -351,10 +351,10 @@ exports.postTransfers = async function (req, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) + Logger.isDebugEnabled && Logger.debug(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - START`) const metadata = `${req.method} ${req.path} ${req.payload.transferId}` - Logger.info(`IN testfsp4:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: received: ${metadata}.`) if (!transfersFulfilResponseDisabled) { // Saving Incoming request @@ -407,14 +407,14 @@ exports.postTransfers = async function (req, h) { }), data: JSON.stringify(transfersResponse) } - // Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) + // Logger.isInfoEnabled && Logger.info(`Executing PUT: [${url}], HEADERS: [${JSON.stringify(opts.headers)}], BODY: [${JSON.stringify(transfersResponse)}]`) const res = await request(url, opts, req.span) - // Logger.info(`response: ${res.status}`) + // Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.ACCEPTED.CODE) { // TODO: how does one identify the failed response? throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -423,8 +423,8 @@ exports.postTransfers = async function (req, h) { destination: req.headers['fspiop-destination'] }) } catch (err) { - Logger.error(err) - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) + Logger.isErrorEnabled && Logger.error(err) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - ERROR`) histTimerEnd({ success: false, fsp: 'payee', @@ -441,7 +441,7 @@ exports.postTransfers = async function (req, h) { // rq.sendError(url, asyncResponses.serverError, rq.defaultHeaders(requesterName, 'participants'), {logger}); } } else { - // Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${req.payload.transferId}, fsp=${req.headers['fspiop-source']}, source=${req.headers['fspiop-source']}, dest=${req.headers['fspiop-destination']}] ~ Simulator::api::payee::postTransfers - END`) histTimerEnd({ success: true, fsp: 'payee', @@ -461,9 +461,9 @@ exports.putTransfersById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - START`) - Logger.info(`IN testfsp4:: PUT /testfsp4/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/transfers/${request.params.id}, PAYLOAD: [${JSON.stringify(request.payload)}]`) // Saving Incoming request const incomingRequest = { @@ -474,7 +474,7 @@ exports.putTransfersById = function (request, h) { correlationCache.set(request.params.id, request.payload) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersById - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersById', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -486,9 +486,9 @@ exports.putTransfersByIdError = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - START`) - Logger.info(`IN testfsp4:: PUT /testfsp4/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/transfers/${request.params.id}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.id, request.payload) // Saving Incoming request @@ -498,7 +498,7 @@ exports.putTransfersByIdError = function (request, h) { } callbackCache.set(request.params.id, incomingRequest) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::putTransfersByIdError - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'putTransfersByIdError', source: request.headers['fspiop-source'], destination: request.headers['fspiop-destination'] }) return h.response().code(Enums.Http.ReturnCodes.OK.CODE) } @@ -510,11 +510,11 @@ exports.getcorrelationId = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - START`) - Logger.info(`IN testfsp4:: PUT /testfsp4/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/correlationid/${request.params.id}, CACHE: [${JSON.stringify(correlationCache.get(request.params.id))}]`) - // Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) + // Logger.isPerfEnabled && Logger.perf(`[cid=${request.payload.transferId}, fsp=${request.headers['fspiop-source']}, source=${request.headers['fspiop-source']}, dest=${request.headers['fspiop-destination']}] ~ Simulator::api::payer::getcorrelationId - END`) histTimerEnd({ success: true, fsp: 'payer', operation: 'getcorrelationId' }) return h.response(correlationCache.get(request.params.id)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } @@ -526,7 +526,7 @@ exports.getRequestById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp4:: PUT /testfsp4/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/requests/${request.params.id}, CACHE: [${JSON.stringify(requestCache.get(request.params.id))}]`) const responseData = requestCache.get(request.params.id) requestCache.del(request.params.id) @@ -542,7 +542,7 @@ exports.getCallbackById = function (request, h) { ['success', 'fsp', 'operation', 'source', 'destination'] ).startTimer() - Logger.info(`IN testfsp4:: PUT /testfsp4/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) + Logger.isInfoEnabled && Logger.info(`IN testfsp4:: PUT /testfsp4/callbacks/${request.params.id}, CACHE: [${JSON.stringify(callbackCache.get(request.params.id))}]`) const responseData = callbackCache.get(request.params.id) callbackCache.del(request.params.id) diff --git a/src/transactionRequests/handler.js b/src/transactionRequests/handler.js index 68c4dc3c..b848e939 100644 --- a/src/transactionRequests/handler.js +++ b/src/transactionRequests/handler.js @@ -39,7 +39,7 @@ const transactionRequestsEndpoint = process.env.TRANSACTION_REQUESTS_ENDPOINT || exports.getTransactionRequestById = function (request, h) { (async () => { - Logger.info(`IN transactionRequests:: Final response for GET /transactionRequests/correlationid/${request.params.ID}, CACHE: [${JSON.stringify(correlationCache.get(request.params.ID))}`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests:: Final response for GET /transactionRequests/correlationid/${request.params.ID}, CACHE: [${JSON.stringify(correlationCache.get(request.params.ID))}`) const url = transactionRequestsEndpoint + '/transactionRequests/' + request.params.ID try { let transactionRequestResponse @@ -76,12 +76,12 @@ exports.getTransactionRequestById = function (request, h) { data: JSON.stringify(transactionRequestResponse) } const res = await sendRequest(url, opts, request.span) - Logger.info(`response: ${res.status}`) + Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.OK.CODE) { throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) } })() @@ -91,7 +91,7 @@ exports.getTransactionRequestById = function (request, h) { exports.postTransactionRequest = function (request, h) { (async () => { const metadata = `${request.method} ${request.path} ${request.payload.transactionRequestId}` - Logger.info(`IN transactionRequests POST:: received: ${metadata}.`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests POST:: received: ${metadata}.`) const url = transactionRequestsEndpoint + '/transactionRequests/' + request.payload.transactionRequestId try { if (requestsCache.get(request.payload.transactionRequestId)) { @@ -128,12 +128,12 @@ exports.postTransactionRequest = function (request, h) { data: JSON.stringify(transactionRequestsResponse) } const res = await sendRequest(url, opts, request.span) - Logger.info(`response: ${res.status}`) + Logger.isInfoEnabled && Logger.info(`response: ${res.status}`) if (res.status !== Enums.Http.ReturnCodes.OK.CODE) { throw new Error(`Failed to send. Result: ${JSON.stringify(res)}`) } } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) } })() @@ -141,7 +141,7 @@ exports.postTransactionRequest = function (request, h) { } exports.putTransactionRequest = function (request, h) { - Logger.info(`IN transactionRequests :: PUT /transactionRequests/${request.params.ID}, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests :: PUT /transactionRequests/${request.params.ID}, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.ID, { headers: request.headers, data: request.payload }) callbackCache.set(request.params.ID, { headers: request.headers, data: request.payload }) @@ -149,7 +149,7 @@ exports.putTransactionRequest = function (request, h) { } exports.putTransactionRequestError = function (request, h) { - Logger.info(`IN transactionRequests :: PUT /transactionRequests/${request.params.ID}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests :: PUT /transactionRequests/${request.params.ID}/error, PAYLOAD: [${JSON.stringify(request.payload)}]`) correlationCache.set(request.params.ID, { headers: request.headers, data: request.payload }) callbackCache.set(request.params.ID, { headers: request.headers, data: request.payload }) @@ -157,13 +157,13 @@ exports.putTransactionRequestError = function (request, h) { } exports.getCorrelationId = function (request, h) { - Logger.info(`IN transactionRequests:: GET /transactionRequests/correlationid/${request.params.ID}, CACHE: [${JSON.stringify(correlationCache.get(request.params.ID))}`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests:: GET /transactionRequests/correlationid/${request.params.ID}, CACHE: [${JSON.stringify(correlationCache.get(request.params.ID))}`) return h.response(correlationCache.get(request.params.ID)).code(Enums.Http.ReturnCodes.ACCEPTED.CODE) } exports.getRequestById = function (request, h) { - Logger.info(`IN transactionRequests :: GET /transactionRequests/requests/${request.params.ID}, CACHE: [${JSON.stringify(requestsCache.get(request.params.ID))}]`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests :: GET /transactionRequests/requests/${request.params.ID}, CACHE: [${JSON.stringify(requestsCache.get(request.params.ID))}]`) const responseData = requestsCache.get(request.params.ID) requestsCache.del(request.params.ID) @@ -171,7 +171,7 @@ exports.getRequestById = function (request, h) { } exports.getCallbackById = function (request, h) { - Logger.info(`IN transactionRequests :: GET /transactionRequests/callbacks/${request.params.ID}, CACHE: [${JSON.stringify(callbackCache.get(request.params.ID))}]`) + Logger.isInfoEnabled && Logger.info(`IN transactionRequests :: GET /transactionRequests/callbacks/${request.params.ID}, CACHE: [${JSON.stringify(callbackCache.get(request.params.ID))}]`) const responseData = callbackCache.get(request.params.ID) callbackCache.del(request.params.ID) @@ -204,6 +204,6 @@ const sendErrorCallback = async (fspiopError, transactionRequestId, headers, spa throw new Error(`Failed to send. Result: ${res}`) } } catch (err) { - Logger.error(err) + Logger.isErrorEnabled && Logger.error(err) } }