@mojaloop/central-services-shared 18.6.0-proxy.3 → 18.6.0-proxy.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-services-shared",
3
- "version": "18.6.0-proxy.3",
3
+ "version": "18.6.0-proxy.4",
4
4
  "description": "Shared code for mojaloop central services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -147,6 +147,8 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderO
147
147
  ).startTimer()
148
148
  switchEndpoint = switchUrl
149
149
  Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::getEndpoint::endpointType - ${endpointType}`)
150
+ let isProxy = false
151
+ const result = url => proxyConfig ? { url, isProxy } : url
150
152
  try {
151
153
  // If a service passes in `getDecoratedValue` as true, then an object
152
154
  // { value, cached, report } is returned, where value is the cached value,
@@ -159,6 +161,7 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderO
159
161
  await proxy.connect()
160
162
  }
161
163
  const proxyId = await proxy.lookupProxyByDfspId(fsp)
164
+ isProxy = true
162
165
  endpoints = proxyId && await policy.get(proxyId)
163
166
  }
164
167
  if (!endpoints) throw ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.PARTY_NOT_FOUND)
@@ -171,16 +174,16 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderO
171
174
  const endpoint = new Map(endpoints.value).get(endpointType)
172
175
  if (renderOptions.path) {
173
176
  const renderedEndpoint = (endpoint === undefined) ? endpoint : endpoint + renderOptions.path
174
- return Mustache.render(renderedEndpoint, options)
177
+ return result(Mustache.render(renderedEndpoint, options))
175
178
  }
176
- return Mustache.render(endpoint, options)
179
+ return result(Mustache.render(endpoint, options))
177
180
  }
178
181
  let endpoint = new Map(endpoints).get(endpointType)
179
182
  if (renderOptions.path) {
180
183
  endpoint = (endpoint === undefined) ? endpoint : endpoint + renderOptions.path
181
184
  }
182
185
  histTimer({ success: true, hit: false })
183
- return Mustache.render(endpoint, options)
186
+ return result(Mustache.render(endpoint, options))
184
187
  } catch (err) {
185
188
  histTimer({ success: false, hit: false })
186
189
  Logger.isErrorEnabled && Logger.error(`participantEndpointCache::getEndpoint:: ERROR:'${err}'`)
@@ -122,8 +122,10 @@ Test('Cache Test', (cacheTest) => {
122
122
  { fsp: proxiedFsp }
123
123
  )
124
124
  const endpointType = FSPIOP_CALLBACK_URL_TRANSFER_PUT
125
- const expected =
126
- 'http://localhost:1080/transfers/97b01bd3-b223-415b-b37b-ab5bef9bdbed'
125
+ const expected = {
126
+ url: 'http://localhost:1080/transfers/97b01bd3-b223-415b-b37b-ab5bef9bdbed',
127
+ isProxy: true
128
+ }
127
129
 
128
130
  await Cache.initializeCache(Config.ENDPOINT_CACHE_CONFIG, {
129
131
  hubName, hubNameRegex
@@ -144,7 +146,7 @@ Test('Cache Test', (cacheTest) => {
144
146
  undefined,
145
147
  {}
146
148
  )
147
- test.equal(result, expected, 'The results match')
149
+ test.deepEqual(result, expected, 'The results match')
148
150
 
149
151
  await Cache.stopCache()
150
152
  test.end()