@mojaloop/central-services-shared 18.34.2 → 18.34.3
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/CHANGELOG.md +7 -0
- package/package.json +6 -6
- package/src/config.js +6 -0
- package/src/util/request.js +2 -0
- package/test/unit/util/request.test.js +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [18.34.3](https://github.com/mojaloop/central-services-shared/compare/v18.34.2...v18.34.3) (2025-10-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Chore
|
|
9
|
+
|
|
10
|
+
* add env config to control http timeout ([#491](https://github.com/mojaloop/central-services-shared/issues/491)) ([9249fb2](https://github.com/mojaloop/central-services-shared/commit/9249fb2b217cf8e337c42d8e3391cbe225984463))
|
|
11
|
+
|
|
5
12
|
### [18.34.2](https://github.com/mojaloop/central-services-shared/compare/v18.34.1...v18.34.2) (2025-10-10)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/central-services-shared",
|
|
3
|
-
"version": "18.34.
|
|
3
|
+
"version": "18.34.3",
|
|
4
4
|
"description": "Shared code for mojaloop central services",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "ModusBox",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"@opentelemetry/api": "1.9.0",
|
|
72
72
|
"async-exit-hook": "2.0.1",
|
|
73
73
|
"async-retry": "1.3.3",
|
|
74
|
-
"axios": "1.
|
|
74
|
+
"axios": "1.13.0",
|
|
75
75
|
"clone": "2.1.2",
|
|
76
76
|
"convict": "^6.2.4",
|
|
77
77
|
"dotenv": "17.2.3",
|
|
78
78
|
"env-var": "7.5.0",
|
|
79
79
|
"event-stream": "4.0.1",
|
|
80
80
|
"fast-safe-stringify": "2.1.1",
|
|
81
|
-
"immutable": "5.1.
|
|
81
|
+
"immutable": "5.1.4",
|
|
82
82
|
"ioredis": "5.6.1",
|
|
83
83
|
"joi": "18.0.1",
|
|
84
84
|
"lodash": "4.17.21",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@mojaloop/central-services-metrics": "12.8.0",
|
|
100
100
|
"@mojaloop/event-sdk": "14.8.1",
|
|
101
101
|
"@mojaloop/sdk-standard-components": "19.18.0",
|
|
102
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
102
|
+
"@opentelemetry/auto-instrumentations-node": "^0.66.0",
|
|
103
103
|
"@types/hapi__joi": "17.1.15",
|
|
104
104
|
"ajv": "^8.17.1",
|
|
105
105
|
"ajv-formats": "^3.0.1",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"audit-ci": "7.1.0",
|
|
108
108
|
"base64url": "3.0.1",
|
|
109
109
|
"chance": "1.1.13",
|
|
110
|
-
"npm-check-updates": "19.
|
|
110
|
+
"npm-check-updates": "19.1.1",
|
|
111
111
|
"nyc": "17.1.0",
|
|
112
112
|
"portfinder": "1.0.38",
|
|
113
113
|
"pre-commit": "1.2.2",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"tapes": "4.1.0"
|
|
124
124
|
},
|
|
125
125
|
"overrides": {
|
|
126
|
-
"axios": "1.
|
|
126
|
+
"axios": "1.13.0",
|
|
127
127
|
"brace-expansion": "2.0.2",
|
|
128
128
|
"form-data": "4.0.4",
|
|
129
129
|
"nanoid": "5.1.5",
|
package/src/config.js
CHANGED
|
@@ -14,6 +14,12 @@ const config = convict({
|
|
|
14
14
|
format: Number,
|
|
15
15
|
default: 300,
|
|
16
16
|
env: 'SHARED_CACHE_DEFAULT_TTL_SEC'
|
|
17
|
+
},
|
|
18
|
+
httpRequestTimeoutMs: {
|
|
19
|
+
doc: 'Timeout for HTTP requests in milliseconds.',
|
|
20
|
+
format: Number,
|
|
21
|
+
default: 20000,
|
|
22
|
+
env: 'SHARED_HTTP_REQUEST_TIMEOUT_MS'
|
|
17
23
|
}
|
|
18
24
|
})
|
|
19
25
|
|
package/src/util/request.js
CHANGED
|
@@ -39,6 +39,7 @@ const Headers = require('./headers/transformer')
|
|
|
39
39
|
const enums = require('../enums')
|
|
40
40
|
const { logger } = require('../logger')
|
|
41
41
|
const { API_TYPES } = require('../constants')
|
|
42
|
+
const config = require('../config')
|
|
42
43
|
|
|
43
44
|
const MISSING_FUNCTION_PARAMETERS = 'Missing parameters for function'
|
|
44
45
|
|
|
@@ -128,6 +129,7 @@ const sendRequest = async ({
|
|
|
128
129
|
data: payload, // todo: think, if it's better to transform to ISO format here (based on apiType)
|
|
129
130
|
params,
|
|
130
131
|
responseType,
|
|
132
|
+
timeout: config.get('httpRequestTimeoutMs'),
|
|
131
133
|
...axiosRequestOptionsOverride
|
|
132
134
|
}
|
|
133
135
|
// if jwsSigner is passed then sign the request
|
|
@@ -603,6 +603,60 @@ Test('ParticipantEndpoint Model Test', modelTest => {
|
|
|
603
603
|
await testErrorWithSpan(test, customError, '1001')
|
|
604
604
|
})
|
|
605
605
|
|
|
606
|
+
getEndpointTest.test('should use default httpRequestTimeoutMs from config', async (test) => {
|
|
607
|
+
// Arrange
|
|
608
|
+
const fsp = 'fsp'
|
|
609
|
+
const requestOptions = {
|
|
610
|
+
url: Mustache.render(Config.ENDPOINT_SOURCE_URL + Enum.EndPoints.FspEndpointTemplates.PARTICIPANT_ENDPOINTS_GET, { fsp }),
|
|
611
|
+
method: 'get'
|
|
612
|
+
}
|
|
613
|
+
let receivedOptions
|
|
614
|
+
request = sandbox.stub().callsFake((options) => {
|
|
615
|
+
receivedOptions = options
|
|
616
|
+
return Helper.getEndPointsResponse
|
|
617
|
+
})
|
|
618
|
+
Model = proxyquire('../../../src/util/request', { axios: request })
|
|
619
|
+
|
|
620
|
+
// Act
|
|
621
|
+
await Model.sendRequest({
|
|
622
|
+
url: requestOptions.url,
|
|
623
|
+
headers: Helper.defaultHeaders(hubName, Enum.Http.HeaderResources.PARTICIPANTS, hubName),
|
|
624
|
+
source: hubName,
|
|
625
|
+
destination: hubName,
|
|
626
|
+
hubNameRegex
|
|
627
|
+
})
|
|
628
|
+
|
|
629
|
+
// Assert
|
|
630
|
+
test.equal(receivedOptions.timeout, require('../../../src/config').get('httpRequestTimeoutMs'), 'Timeout is set from config')
|
|
631
|
+
test.end()
|
|
632
|
+
})
|
|
633
|
+
|
|
634
|
+
getEndpointTest.test('should allow overriding httpRequestTimeoutMs via axiosRequestOptionsOverride', async (test) => {
|
|
635
|
+
// Arrange
|
|
636
|
+
const fsp = 'fsp'
|
|
637
|
+
const overrideTimeout = 12345
|
|
638
|
+
let receivedTimeout
|
|
639
|
+
const requestFunction = (requestOptions) => {
|
|
640
|
+
receivedTimeout = requestOptions.timeout
|
|
641
|
+
return Helper.getEndPointsResponse
|
|
642
|
+
}
|
|
643
|
+
Model = proxyquire('../../../src/util/request', { axios: requestFunction })
|
|
644
|
+
|
|
645
|
+
// Act
|
|
646
|
+
await Model.sendRequest({
|
|
647
|
+
url: Mustache.render(Config.ENDPOINT_SOURCE_URL + Enum.EndPoints.FspEndpointTemplates.PARTICIPANT_ENDPOINTS_GET, { fsp }),
|
|
648
|
+
headers: Helper.defaultHeaders(hubName, Enum.Http.HeaderResources.PARTICIPANTS, hubName),
|
|
649
|
+
source: hubName,
|
|
650
|
+
destination: hubName,
|
|
651
|
+
hubNameRegex,
|
|
652
|
+
axiosRequestOptionsOverride: { timeout: overrideTimeout }
|
|
653
|
+
})
|
|
654
|
+
|
|
655
|
+
// Assert
|
|
656
|
+
test.equal(receivedTimeout, overrideTimeout, 'Timeout is overridden by axiosRequestOptionsOverride')
|
|
657
|
+
test.end()
|
|
658
|
+
})
|
|
659
|
+
|
|
606
660
|
getEndpointTest.end()
|
|
607
661
|
})
|
|
608
662
|
|