account-lookup-service 17.12.3-connection-lost.0 → 17.12.3-snapshot.0
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,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "account-lookup-service",
|
3
3
|
"description": "Account Lookup Service is used to validate Party and Participant lookups.",
|
4
|
-
"version": "17.12.3-
|
4
|
+
"version": "17.12.3-snapshot.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
package/src/lib/config.js
CHANGED
@@ -175,7 +175,8 @@ const config = {
|
|
175
175
|
FEATURE_ENABLE_EXTENDED_PARTY_ID_TYPE: RC.FEATURE_ENABLE_EXTENDED_PARTY_ID_TYPE || false,
|
176
176
|
PROTOCOL_VERSIONS: getProtocolVersions(DEFAULT_PROTOCOL_VERSION, RC.PROTOCOL_VERSIONS),
|
177
177
|
PROXY_CACHE_CONFIG: RC.PROXY_CACHE,
|
178
|
-
DELETE_PARTICIPANT_VALIDATION_ENABLED: RC.DELETE_PARTICIPANT_VALIDATION_ENABLED || false
|
178
|
+
DELETE_PARTICIPANT_VALIDATION_ENABLED: RC.DELETE_PARTICIPANT_VALIDATION_ENABLED || false,
|
179
|
+
HTTP_REQUEST_TIMEOUT_MS: RC.HTTP_REQUEST_TIMEOUT_MS ?? 20_000
|
179
180
|
}
|
180
181
|
|
181
182
|
if (config.JWS_SIGN) {
|
@@ -43,7 +43,10 @@ const { Headers, RestMethods, ReturnCodes } = Enums.Http
|
|
43
43
|
const sendHttpRequest = ({ method, ...restArgs }) => request.sendRequest({
|
44
44
|
...restArgs,
|
45
45
|
method: method.toUpperCase(),
|
46
|
-
hubNameRegex
|
46
|
+
hubNameRegex,
|
47
|
+
axiosRequestOptionsOverride: {
|
48
|
+
timeout: Config.HTTP_REQUEST_TIMEOUT_MS
|
49
|
+
}
|
47
50
|
})
|
48
51
|
|
49
52
|
/**
|
@@ -37,6 +37,9 @@ const { logger } = require('../../lib')
|
|
37
37
|
const { hubNameRegex } = require('../../lib/util').hubNameConfig
|
38
38
|
|
39
39
|
const uriRegex = /(?:^.*)(\/(participants|parties|quotes|transfers)(\/.*)*)$/
|
40
|
+
const axiosRequestOptionsOverride = {
|
41
|
+
timeout: Config.HTTP_REQUEST_TIMEOUT_MS
|
42
|
+
}
|
40
43
|
|
41
44
|
/**
|
42
45
|
* @module src/models/participantEndpoint/facade
|
@@ -115,7 +118,8 @@ exports.sendRequest = async (headers, requestedParticipant, endpointType, method
|
|
115
118
|
span,
|
116
119
|
protocolVersions,
|
117
120
|
hubNameRegex,
|
118
|
-
apiType: Config.API_TYPE
|
121
|
+
apiType: Config.API_TYPE,
|
122
|
+
axiosRequestOptionsOverride
|
119
123
|
}
|
120
124
|
logger.debug('participant - sendRequest params:', { params })
|
121
125
|
params.jwsSigner = defineJwsSigner(Config, headers, requestedEndpoint)
|
@@ -252,7 +256,8 @@ exports.sendErrorToParticipant = async (participantName, endpointType, errorInfo
|
|
252
256
|
hubNameRegex,
|
253
257
|
span,
|
254
258
|
protocolVersions,
|
255
|
-
apiType: Config.API_TYPE
|
259
|
+
apiType: Config.API_TYPE,
|
260
|
+
axiosRequestOptionsOverride
|
256
261
|
}
|
257
262
|
logger.debug('participant - sendErrorToParticipant params: ', { params })
|
258
263
|
params.jwsSigner = defineJwsSigner(Config, clonedHeaders, requesterErrorEndpoint)
|
package/src/server.js
CHANGED
@@ -45,12 +45,6 @@ const OracleEndpointCache = require('./models/oracle/oracleEndpointCached')
|
|
45
45
|
const Handlers = require('./handlers/register')
|
46
46
|
|
47
47
|
const connectDatabase = async (dbConfig) => {
|
48
|
-
if (dbConfig.pool) {
|
49
|
-
dbConfig.pool.afterCreate = (connection, done) => {
|
50
|
-
connection.on('end', () => { connection.__knex__disposed = 'Connection ended' })
|
51
|
-
done(null, connection)
|
52
|
-
}
|
53
|
-
}
|
54
48
|
await Db.connect(dbConfig)
|
55
49
|
logger.info('Database connected')
|
56
50
|
}
|
@@ -188,6 +188,26 @@ describe('participantEndpoint Facade', () => {
|
|
188
188
|
|
189
189
|
expect(mockSendRequest.mock.lastCall[0].jwsSigner).toBeTruthy()
|
190
190
|
})
|
191
|
+
|
192
|
+
it('should add default timeout to sendRequest', async () => {
|
193
|
+
const mockedConfig = {
|
194
|
+
JWS_SIGN: false,
|
195
|
+
FSPIOP_SOURCE_TO_SIGN: mockHubName,
|
196
|
+
PROTOCOL_VERSIONS: fixtures.protocolVersionsDto(),
|
197
|
+
HTTP_REQUEST_TIMEOUT_MS: 1000
|
198
|
+
}
|
199
|
+
jest.mock('../../../../src/lib/config', () => (mockedConfig))
|
200
|
+
mockGetEndpoint.mockImplementation(() => 'https://example.com/12345')
|
201
|
+
mockSendRequest.mockImplementation(async () => true)
|
202
|
+
const ParticipantFacade = require(`${src}/models/participantEndpoint/facade`)
|
203
|
+
|
204
|
+
const headers = {}
|
205
|
+
const requestedParticipant = {}
|
206
|
+
const endpointType = 'URL'
|
207
|
+
|
208
|
+
await ParticipantFacade.sendRequest(headers, requestedParticipant, endpointType)
|
209
|
+
expect(mockSendRequest.mock.calls[0][0].axiosRequestOptionsOverride.timeout).toBe(mockedConfig.HTTP_REQUEST_TIMEOUT_MS)
|
210
|
+
})
|
191
211
|
})
|
192
212
|
|
193
213
|
describe('validateParticipant', () => {
|