@mojaloop/sdk-scheme-adapter 24.2.0 → 24.3.0-snapshot.1
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/.yarn/cache/@hapi-hapi-npm-21.4.0-2644a983d1-4e6ccd65ba.zip +0 -0
- package/.yarn/cache/@hapi-statehood-npm-8.2.0-5844e85740-0ebe5fa44e.zip +0 -0
- package/.yarn/cache/@mojaloop-central-services-shared-npm-18.22.1-afa19f2925-27182cd5be.zip +0 -0
- package/.yarn/cache/{@mojaloop-event-sdk-npm-14.1.5-97dbf6c0e3-9d5836df5a.zip → @mojaloop-event-sdk-npm-14.3.0-2aa8149477-6173c7d96f.zip} +0 -0
- package/.yarn/cache/@mojaloop-inter-scheme-proxy-cache-lib-npm-2.3.7-87034262d3-37fe9b388c.zip +0 -0
- package/.yarn/cache/@mojaloop-sdk-standard-components-npm-19.10.0-snapshot.2-c380c8c569-c7ec67c802.zip +0 -0
- package/.yarn/cache/{@types-node-npm-22.13.9-565bb4cd14-d36ae841fa.zip → @types-node-npm-22.13.10-af5336e62b-1cd6b899df.zip} +0 -0
- package/.yarn/cache/axios-npm-1.8.2-55671cda10-c47a43b79a.zip +0 -0
- package/.yarn/cache/ioredis-npm-5.6.0-2140ad9baf-b085cec251.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/modules/api-svc/package.json +5 -5
- package/modules/api-svc/src/BackendEventHandler/index.js +1 -1
- package/modules/api-svc/src/ControlAgent/index.js +1 -1
- package/modules/api-svc/src/FSPIOPEventHandler/index.js +1 -1
- package/modules/api-svc/src/InboundServer/index.js +3 -3
- package/modules/api-svc/src/OAuthTestServer/index.js +1 -1
- package/modules/api-svc/src/OutboundServer/index.js +3 -3
- package/modules/api-svc/src/TestServer/index.js +3 -3
- package/modules/api-svc/src/config.js +2 -2
- package/modules/api-svc/src/index.js +24 -45
- package/modules/api-svc/src/lib/cache.js +1 -1
- package/modules/api-svc/src/lib/logger.js +49 -0
- package/modules/api-svc/src/lib/metrics.js +2 -2
- package/modules/api-svc/src/lib/model/InboundTransfersModel.js +1 -1
- package/modules/api-svc/src/lib/model/OutboundTransfersModel.js +1 -1
- package/modules/api-svc/src/lib/model/lib/requests/backendRequests.js +1 -1
- package/modules/api-svc/src/lib/utils.js +1 -19
- package/modules/api-svc/test/integration/lib/cache.test.js +2 -7
- package/modules/api-svc/test/integration-pm4ml/mockServers/managementService/config.js +3 -2
- package/modules/api-svc/test/integration-pm4ml/mockServers/managementService/index.js +18 -24
- package/modules/api-svc/test/integration-pm4ml/mockServers/managementService/server.js +0 -1
- package/modules/api-svc/test/unit/BackendEventHandler.test.js +1 -3
- package/modules/api-svc/test/unit/ControlClient.test.js +5 -5
- package/modules/api-svc/test/unit/FSPIOPEventHandler.test.js +4 -5
- package/modules/api-svc/test/unit/InboundServer-iso20022.test.js +2 -4
- package/modules/api-svc/test/unit/InboundServer.test.js +2 -3
- package/modules/api-svc/test/unit/TestServer.test.js +10 -14
- package/modules/api-svc/test/unit/api/transfers/utils.js +1 -2
- package/modules/api-svc/test/unit/api/utils.js +3 -3
- package/modules/api-svc/test/unit/ilp.test.js +3 -2
- package/modules/api-svc/test/unit/inboundApi/handlers-iso20022.test.js +4 -6
- package/modules/api-svc/test/unit/inboundApi/handlers.test.js +27 -28
- package/modules/api-svc/test/unit/index.test.js +9 -14
- package/modules/api-svc/test/unit/lib/cache.test.js +1 -2
- package/modules/api-svc/test/unit/lib/model/AccountsModel.test.js +2 -6
- package/modules/api-svc/test/unit/lib/model/InboundTransfersModel.test.js +9 -12
- package/modules/api-svc/test/unit/lib/model/OutboundBulkQuotesModel.test.js +3 -5
- package/modules/api-svc/test/unit/lib/model/OutboundBulkTransfersModel.test.js +2 -6
- package/modules/api-svc/test/unit/lib/model/OutboundRequestToPayModel.test.js +4 -5
- package/modules/api-svc/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +3 -5
- package/modules/api-svc/test/unit/lib/model/OutboundTransfersISO20022.test.js +4 -7
- package/modules/api-svc/test/unit/lib/model/OutboundTransfersModel.test.js +3 -4
- package/modules/api-svc/test/unit/lib/model/lib/requests/backendRequests.test.js +3 -2
- package/modules/api-svc/test/unit/mockLogger.js +10 -7
- package/modules/outbound-command-event-handler/package.json +3 -3
- package/modules/outbound-domain-event-handler/package.json +2 -2
- package/modules/private-shared-lib/package-lock.json +2 -2
- package/modules/private-shared-lib/package.json +3 -3
- package/package.json +2 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/cache/@mojaloop-inter-scheme-proxy-cache-lib-npm-2.3.7-87034262d3-37fe9b388c.zip
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter-api-svc",
|
|
3
|
-
"version": "21.0.0-snapshot.
|
|
3
|
+
"version": "21.0.0-snapshot.29",
|
|
4
4
|
"description": "An adapter for connecting to Mojaloop API enabled switches.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
"@mojaloop/central-services-error-handling": "13.0.7",
|
|
69
69
|
"@mojaloop/central-services-logger": "11.5.5",
|
|
70
70
|
"@mojaloop/central-services-metrics": "12.4.5",
|
|
71
|
-
"@mojaloop/central-services-shared": "18.
|
|
72
|
-
"@mojaloop/event-sdk": "14.
|
|
71
|
+
"@mojaloop/central-services-shared": "18.22.1",
|
|
72
|
+
"@mojaloop/event-sdk": "14.3.0",
|
|
73
73
|
"@mojaloop/logging-bc-client-lib": "0.5.8",
|
|
74
74
|
"@mojaloop/ml-schema-transformer-lib": "2.5.6",
|
|
75
75
|
"@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^",
|
|
76
|
-
"@mojaloop/sdk-standard-components": "19.
|
|
76
|
+
"@mojaloop/sdk-standard-components": "19.10.0-snapshot.2",
|
|
77
77
|
"ajv": "8.17.1",
|
|
78
|
-
"axios": "1.8.
|
|
78
|
+
"axios": "1.8.2",
|
|
79
79
|
"body-parser": "1.20.3",
|
|
80
80
|
"co-body": "6.2.0",
|
|
81
81
|
"dotenv": "16.4.7",
|
|
@@ -50,7 +50,7 @@ class BackendEventHandler {
|
|
|
50
50
|
constructor({ config, logger }) {
|
|
51
51
|
this._conf = config;
|
|
52
52
|
|
|
53
|
-
this._logger = logger;
|
|
53
|
+
this._logger = logger.push({ component: this.constructor.name });
|
|
54
54
|
this._loggerFromLoggingBC = new DefaultLogger(BC_CONFIG.bcName, 'backend-event-handler', '0.0.1', config.logLevel);
|
|
55
55
|
|
|
56
56
|
this._backendRequests = new BackendRequests({
|
|
@@ -143,7 +143,7 @@ class Client extends ws {
|
|
|
143
143
|
*/
|
|
144
144
|
constructor({ address = 'localhost', port, logger, appConfig }) {
|
|
145
145
|
super(`ws://${address}:${port}`);
|
|
146
|
-
this._logger = logger;
|
|
146
|
+
this._logger = logger.push({ component: 'ControlClient' });
|
|
147
147
|
this._appConfig = appConfig;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -62,7 +62,7 @@ class InboundApi extends EventEmitter {
|
|
|
62
62
|
}
|
|
63
63
|
this._api = InboundApi._SetupApi({
|
|
64
64
|
conf,
|
|
65
|
-
logger,
|
|
65
|
+
logger: logger.push({ component: this.constructor.name }),
|
|
66
66
|
validator,
|
|
67
67
|
cache,
|
|
68
68
|
jwsVerificationKeys: this._jwsVerificationKeys,
|
|
@@ -159,10 +159,10 @@ class InboundServer extends EventEmitter {
|
|
|
159
159
|
constructor(conf, logger, cache, wso2) {
|
|
160
160
|
super({ captureExceptions: true });
|
|
161
161
|
this._conf = conf;
|
|
162
|
-
this._logger = logger;
|
|
162
|
+
this._logger = logger.push({ app: this.constructor.name });
|
|
163
163
|
this._api = new InboundApi(
|
|
164
164
|
conf,
|
|
165
|
-
this._logger
|
|
165
|
+
this._logger,
|
|
166
166
|
cache,
|
|
167
167
|
_validator,
|
|
168
168
|
wso2,
|
|
@@ -47,7 +47,7 @@ class OAuthTestServer {
|
|
|
47
47
|
*/
|
|
48
48
|
constructor({ port, clientKey, clientSecret, logger }) {
|
|
49
49
|
this._port = port;
|
|
50
|
-
this._logger = logger;
|
|
50
|
+
this._logger = logger.push({ component: this.constructor.name });
|
|
51
51
|
this._clientKey = clientKey;
|
|
52
52
|
this._clientSecret = clientSecret;
|
|
53
53
|
}
|
|
@@ -53,7 +53,7 @@ let _initialize;
|
|
|
53
53
|
class OutboundApi extends EventEmitter {
|
|
54
54
|
constructor(conf, logger, cache, validator, metricsClient, wso2, eventProducer, eventLogger) {
|
|
55
55
|
super({ captureExceptions: true });
|
|
56
|
-
this._logger = logger;
|
|
56
|
+
this._logger = logger.push({ component: this.constructor.name });
|
|
57
57
|
this._api = new Koa();
|
|
58
58
|
this._conf = conf;
|
|
59
59
|
this._cache = cache;
|
|
@@ -109,7 +109,7 @@ class OutboundServer extends EventEmitter {
|
|
|
109
109
|
constructor(conf, logger, cache, metricsClient, wso2) {
|
|
110
110
|
super({ captureExceptions: true });
|
|
111
111
|
this._conf = conf;
|
|
112
|
-
this._logger = logger;
|
|
112
|
+
this._logger = logger.push({ app: this.constructor.name });
|
|
113
113
|
this._server = null;
|
|
114
114
|
if (conf.backendEventHandler.enabled) {
|
|
115
115
|
this._eventLogger = new DefaultLogger(BC_CONFIG.bcName, 'backend-api-handler', '0.0.1', conf.logLevel);
|
|
@@ -118,7 +118,7 @@ class OutboundServer extends EventEmitter {
|
|
|
118
118
|
}
|
|
119
119
|
this._api = new OutboundApi(
|
|
120
120
|
conf,
|
|
121
|
-
this._logger
|
|
121
|
+
this._logger,
|
|
122
122
|
cache,
|
|
123
123
|
_validator,
|
|
124
124
|
metricsClient,
|
|
@@ -194,12 +194,12 @@ class TestServer {
|
|
|
194
194
|
constructor({ port, logger, cache, config }) {
|
|
195
195
|
_initialize ||= _validator.initialise(yaml.load(require('fs').readFileSync(path.join(__dirname, 'api.yaml'))), config);
|
|
196
196
|
this._port = port;
|
|
197
|
-
this._logger = logger;
|
|
198
|
-
this._api = new TestApi(this._logger.push({ component: '
|
|
197
|
+
this._logger = logger.push({ app: this.constructor.name });
|
|
198
|
+
this._api = new TestApi(this._logger.push({ component: 'TestApi' }), _validator, cache, config);
|
|
199
199
|
this._server = http.createServer(this._api.callback());
|
|
200
200
|
// TODO: why does this appear to need to be called after creating this._server (try reorder
|
|
201
201
|
// it then run the tests)
|
|
202
|
-
this._wsapi = new WsServer(this._logger.push({ component: '
|
|
202
|
+
this._wsapi = new WsServer(this._logger.push({ component: 'WsServer' }), cache);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
async start() {
|
|
@@ -30,7 +30,7 @@ require('dotenv').config();
|
|
|
30
30
|
const fs = require('node:fs');
|
|
31
31
|
const yaml = require('js-yaml');
|
|
32
32
|
const { from } = require('env-var');
|
|
33
|
-
const {
|
|
33
|
+
const { LOG_LEVELS } = require('./lib/logger');
|
|
34
34
|
const { API_TYPES, RESOURCE_VERSIONS_STRING } = require('./constants');
|
|
35
35
|
|
|
36
36
|
function getFileContent (path) {
|
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
|
90
90
|
mgmtAPILatencyAssumption: env.get('MGMT_API_LATENCY_ASSUMPTION').default('2000').asIntPositive(),
|
|
91
91
|
},
|
|
92
92
|
idGenerator: env.get('ID_GENERATOR').default('{"type":"ulid"}').asJsonObject(),
|
|
93
|
-
logLevel: env.get('LOG_LEVEL').default('info').asEnum(
|
|
93
|
+
logLevel: env.get('LOG_LEVEL').default('info').asEnum(LOG_LEVELS),
|
|
94
94
|
inbound: {
|
|
95
95
|
port: env.get('INBOUND_LISTEN_PORT').default('4000').asPortNumber(),
|
|
96
96
|
tls: {
|
|
@@ -48,25 +48,14 @@ const Router = require('./lib/router');
|
|
|
48
48
|
const Validate = require('./lib/validate');
|
|
49
49
|
const Cache = require('./lib/cache');
|
|
50
50
|
const { SDKStateEnum } = require('./lib/model/common');
|
|
51
|
-
const { createAuthClient
|
|
52
|
-
|
|
53
|
-
const LOG_ID = {
|
|
54
|
-
INBOUND: { app: 'mojaloop-connector-inbound-api' },
|
|
55
|
-
OUTBOUND: { app: 'mojaloop-connector-outbound-api' },
|
|
56
|
-
BACKEND_EVENT_HANDLER: { app: 'backend-event-handler' },
|
|
57
|
-
FSPIOP_EVENT_HANDLER: { app: 'fspiop-event-handler' },
|
|
58
|
-
TEST: { app: 'mojaloop-connector-test-api' },
|
|
59
|
-
OAUTHTEST: { app: 'mojaloop-connector-oauth-test-server' },
|
|
60
|
-
CONTROL: { app: 'mojaloop-connector-control-client' },
|
|
61
|
-
METRICS: { app: 'mojaloop-connector-metrics' },
|
|
62
|
-
CACHE: { component: 'cache' },
|
|
63
|
-
};
|
|
51
|
+
const { createAuthClient } = require('./lib/utils');
|
|
52
|
+
const { logger } = require('./lib/logger');
|
|
64
53
|
|
|
65
54
|
const PING_INTERVAL_MS = 30000;
|
|
66
55
|
|
|
67
|
-
const createCache = (config
|
|
56
|
+
const createCache = (config) => new Cache({
|
|
57
|
+
logger,
|
|
68
58
|
cacheUrl: config.cacheUrl,
|
|
69
|
-
logger: logger.push(LOG_ID.CACHE),
|
|
70
59
|
enableTestFeatures: config.enableTestFeatures,
|
|
71
60
|
subscribeTimeoutSeconds: config.requestProcessingTimeoutSeconds,
|
|
72
61
|
});
|
|
@@ -79,14 +68,14 @@ class Server extends EventEmitter {
|
|
|
79
68
|
super({ captureExceptions: true });
|
|
80
69
|
this.conf = conf;
|
|
81
70
|
this.logger = logger;
|
|
82
|
-
this.cache = createCache(conf
|
|
71
|
+
this.cache = createCache(conf);
|
|
83
72
|
this.pingTimeout;
|
|
84
73
|
|
|
85
74
|
this.metricsClient = new MetricsClient();
|
|
86
75
|
|
|
87
76
|
this.metricsServer = new MetricsServer({
|
|
88
77
|
port: this.conf.metrics.port,
|
|
89
|
-
logger: this.logger
|
|
78
|
+
logger: this.logger
|
|
90
79
|
});
|
|
91
80
|
|
|
92
81
|
this.wso2 = createAuthClient(conf, logger);
|
|
@@ -96,7 +85,7 @@ class Server extends EventEmitter {
|
|
|
96
85
|
|
|
97
86
|
this.inboundServer = new InboundServer(
|
|
98
87
|
this.conf,
|
|
99
|
-
this.logger
|
|
88
|
+
this.logger,
|
|
100
89
|
this.cache,
|
|
101
90
|
this.wso2,
|
|
102
91
|
);
|
|
@@ -107,7 +96,7 @@ class Server extends EventEmitter {
|
|
|
107
96
|
|
|
108
97
|
this.outboundServer = new OutboundServer(
|
|
109
98
|
this.conf,
|
|
110
|
-
this.logger
|
|
99
|
+
this.logger,
|
|
111
100
|
this.cache,
|
|
112
101
|
this.metricsClient,
|
|
113
102
|
this.wso2,
|
|
@@ -122,7 +111,7 @@ class Server extends EventEmitter {
|
|
|
122
111
|
clientKey: this.conf.oauthTestServer.clientKey,
|
|
123
112
|
clientSecret: this.conf.oauthTestServer.clientSecret,
|
|
124
113
|
port: this.conf.oauthTestServer.listenPort,
|
|
125
|
-
logger: this.logger
|
|
114
|
+
logger: this.logger,
|
|
126
115
|
});
|
|
127
116
|
}
|
|
128
117
|
|
|
@@ -130,7 +119,7 @@ class Server extends EventEmitter {
|
|
|
130
119
|
this.testServer = new TestServer({
|
|
131
120
|
config: this.conf,
|
|
132
121
|
port: this.conf.test.port,
|
|
133
|
-
logger: this.logger
|
|
122
|
+
logger: this.logger,
|
|
134
123
|
cache: this.cache,
|
|
135
124
|
});
|
|
136
125
|
}
|
|
@@ -138,14 +127,14 @@ class Server extends EventEmitter {
|
|
|
138
127
|
if (this.conf.backendEventHandler.enabled) {
|
|
139
128
|
this.backendEventHandler = new BackendEventHandler({
|
|
140
129
|
config: this.conf,
|
|
141
|
-
logger: this.logger
|
|
130
|
+
logger: this.logger,
|
|
142
131
|
});
|
|
143
132
|
}
|
|
144
133
|
|
|
145
134
|
if (this.conf.fspiopEventHandler.enabled) {
|
|
146
135
|
this.fspiopEventHandler = new FSPIOPEventHandler({
|
|
147
136
|
config: this.conf,
|
|
148
|
-
logger: this.logger
|
|
137
|
+
logger: this.logger,
|
|
149
138
|
cache: this.cache,
|
|
150
139
|
wso2: this.wso2,
|
|
151
140
|
});
|
|
@@ -165,7 +154,7 @@ class Server extends EventEmitter {
|
|
|
165
154
|
this.controlClient = await ControlAgent.Client.Create({
|
|
166
155
|
address: this.conf.control.mgmtAPIWsUrl,
|
|
167
156
|
port: this.conf.control.mgmtAPIWsPort,
|
|
168
|
-
logger: this.logger
|
|
157
|
+
logger: this.logger,
|
|
169
158
|
appConfig: this.conf,
|
|
170
159
|
});
|
|
171
160
|
this.controlClient.on(ControlAgent.EVENT.RECONFIGURE, this.restart.bind(this));
|
|
@@ -211,13 +200,7 @@ class Server extends EventEmitter {
|
|
|
211
200
|
|
|
212
201
|
async restart(newConf) {
|
|
213
202
|
const restartActionsTaken = {};
|
|
214
|
-
|
|
215
203
|
this.logger.isDebugEnabled && this.logger.debug('Server is restarting...');
|
|
216
|
-
const updateLogger = !_.isEqual(newConf.isJsonOutput, this.conf.isJsonOutput);
|
|
217
|
-
if (updateLogger) {
|
|
218
|
-
this.logger = createLogger(newConf);
|
|
219
|
-
restartActionsTaken.updateLogger = true;
|
|
220
|
-
}
|
|
221
204
|
|
|
222
205
|
let oldCache;
|
|
223
206
|
const updateCache = !_.isEqual(this.conf.cacheUrl, newConf.cacheUrl)
|
|
@@ -225,7 +208,7 @@ class Server extends EventEmitter {
|
|
|
225
208
|
if (updateCache) {
|
|
226
209
|
oldCache = this.cache;
|
|
227
210
|
await this.cache.disconnect();
|
|
228
|
-
this.cache = createCache(newConf
|
|
211
|
+
this.cache = createCache(newConf);
|
|
229
212
|
await this.cache.connect();
|
|
230
213
|
restartActionsTaken.updateCache = true;
|
|
231
214
|
}
|
|
@@ -249,7 +232,7 @@ class Server extends EventEmitter {
|
|
|
249
232
|
await this.inboundServer.stop();
|
|
250
233
|
this.inboundServer = new InboundServer(
|
|
251
234
|
newConf,
|
|
252
|
-
this.logger
|
|
235
|
+
this.logger,
|
|
253
236
|
this.cache,
|
|
254
237
|
this.wso2,
|
|
255
238
|
);
|
|
@@ -268,7 +251,7 @@ class Server extends EventEmitter {
|
|
|
268
251
|
await this.outboundServer.stop();
|
|
269
252
|
this.outboundServer = new OutboundServer(
|
|
270
253
|
newConf,
|
|
271
|
-
this.logger
|
|
254
|
+
this.logger,
|
|
272
255
|
this.cache,
|
|
273
256
|
this.metricsClient,
|
|
274
257
|
this.wso2,
|
|
@@ -288,7 +271,7 @@ class Server extends EventEmitter {
|
|
|
288
271
|
await this.fspiopEventHandler.stop();
|
|
289
272
|
this.fspiopEventHandler = new FSPIOPEventHandler({
|
|
290
273
|
config: newConf,
|
|
291
|
-
logger: this.logger
|
|
274
|
+
logger: this.logger,
|
|
292
275
|
cache: this.cache,
|
|
293
276
|
wso2: this.wso2,
|
|
294
277
|
});
|
|
@@ -304,7 +287,7 @@ class Server extends EventEmitter {
|
|
|
304
287
|
this.controlClient = await ControlAgent.Client.Create({
|
|
305
288
|
address: newConf.control.mgmtAPIWsUrl,
|
|
306
289
|
port: newConf.control.mgmtAPIWsPort,
|
|
307
|
-
logger: this.logger
|
|
290
|
+
logger: this.logger,
|
|
308
291
|
appConfig: newConf,
|
|
309
292
|
});
|
|
310
293
|
this.controlClient.on(ControlAgent.EVENT.RECONFIGURE, this.restart.bind(this));
|
|
@@ -347,7 +330,7 @@ class Server extends EventEmitter {
|
|
|
347
330
|
clientKey: newConf.oauthTestServer.clientKey,
|
|
348
331
|
clientSecret: newConf.oauthTestServer.clientSecret,
|
|
349
332
|
port: newConf.oauthTestServer.listenPort,
|
|
350
|
-
logger: this.logger
|
|
333
|
+
logger: this.logger,
|
|
351
334
|
});
|
|
352
335
|
await this.oauthTestServer.start();
|
|
353
336
|
restartActionsTaken.updateOAuthTestServer = true;
|
|
@@ -360,7 +343,7 @@ class Server extends EventEmitter {
|
|
|
360
343
|
if (this.conf.enableTestFeatures) {
|
|
361
344
|
this.testServer = new TestServer({
|
|
362
345
|
port: newConf.test.port,
|
|
363
|
-
logger: this.logger
|
|
346
|
+
logger: this.logger,
|
|
364
347
|
cache: this.cache,
|
|
365
348
|
});
|
|
366
349
|
await this.testServer.start();
|
|
@@ -370,14 +353,12 @@ class Server extends EventEmitter {
|
|
|
370
353
|
|
|
371
354
|
this.conf = newConf;
|
|
372
355
|
|
|
373
|
-
await
|
|
374
|
-
oldCache?.disconnect(),
|
|
375
|
-
]);
|
|
356
|
+
await oldCache?.disconnect();
|
|
376
357
|
|
|
377
358
|
if (Object.keys(restartActionsTaken).length > 0) {
|
|
378
|
-
this.logger.
|
|
359
|
+
this.logger.info('Server is restarted', { restartActionsTaken });
|
|
379
360
|
} else {
|
|
380
|
-
this.logger.
|
|
361
|
+
this.logger.verbose('Server not restarted, no config changes detected');
|
|
381
362
|
}
|
|
382
363
|
}
|
|
383
364
|
|
|
@@ -413,8 +394,6 @@ async function _GetUpdatedConfigFromMgmtAPI(conf, logger, client) {
|
|
|
413
394
|
}
|
|
414
395
|
|
|
415
396
|
async function start(config) {
|
|
416
|
-
const logger = createLogger(config);
|
|
417
|
-
|
|
418
397
|
if (config.pm4mlEnabled) {
|
|
419
398
|
const controlClient = await ControlAgent.Client.Create({
|
|
420
399
|
appConfig: config,
|
|
@@ -446,7 +425,7 @@ async function start(config) {
|
|
|
446
425
|
process.exit(1);
|
|
447
426
|
});
|
|
448
427
|
|
|
449
|
-
logger.
|
|
428
|
+
logger.info('SDK server is started!', { name, version });
|
|
450
429
|
}
|
|
451
430
|
|
|
452
431
|
if (require.main === module) {
|
|
@@ -46,7 +46,7 @@ class Cache {
|
|
|
46
46
|
throw new Error('Cache config requires cacheUrl and logger properties');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
this._logger = config.logger;
|
|
49
|
+
this._logger = config.logger.push({ component: this.constructor.name });
|
|
50
50
|
this._url = config.cacheUrl;
|
|
51
51
|
|
|
52
52
|
// a redis connection to handle get, set and publish operations
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2025 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop 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
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* Mojaloop Foundation
|
|
23
|
+
* Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
|
24
|
+
|
|
25
|
+
--------------
|
|
26
|
+
******/
|
|
27
|
+
|
|
28
|
+
const { hostname } = require('node:os');
|
|
29
|
+
const { loggerFactory, LOG_LEVELS } = require('@mojaloop/sdk-standard-components').Logger;
|
|
30
|
+
|
|
31
|
+
const createLogger = (conf = {}) => {
|
|
32
|
+
const {
|
|
33
|
+
context = {
|
|
34
|
+
// If we're running from a Mojaloop helm chart deployment, we'll have a SIM_NAME
|
|
35
|
+
simulator: process.env['SIM_NAME'],
|
|
36
|
+
hostname: hostname(),
|
|
37
|
+
},
|
|
38
|
+
isJsonOutput = false,
|
|
39
|
+
} = conf;
|
|
40
|
+
|
|
41
|
+
return loggerFactory({ context, isJsonOutput });
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const logger = createLogger(); // global logger
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
logger,
|
|
48
|
+
LOG_LEVELS,
|
|
49
|
+
};
|
|
@@ -113,12 +113,12 @@ class MetricsClient {
|
|
|
113
113
|
class MetricsServer {
|
|
114
114
|
/**
|
|
115
115
|
* @param {number} port metrics server listen port
|
|
116
|
-
* @param {Logger} logger
|
|
116
|
+
* @param {Logger} logger SdkLogger
|
|
117
117
|
* @param {Object} prometheusClient Prometheus client instance
|
|
118
118
|
*/
|
|
119
119
|
constructor({ port, logger }) {
|
|
120
120
|
this._port = port;
|
|
121
|
-
this._logger = logger;
|
|
121
|
+
this._logger = logger.push({ component: this.constructor.name });
|
|
122
122
|
this._prometheusClient = PrometheusClient;
|
|
123
123
|
this._prometheusRegister = PrometheusClient.register;
|
|
124
124
|
this._api = this.setupApi();
|
|
@@ -44,7 +44,7 @@ const TRACESTATE_KEY_CALLBACK_START_TS = 'tx_callback_start_ts';
|
|
|
44
44
|
class InboundTransfersModel {
|
|
45
45
|
constructor(config) {
|
|
46
46
|
this._cache = config.cache;
|
|
47
|
-
this._logger = config.logger;
|
|
47
|
+
this._logger = config.logger.push({ component: this.constructor.name });
|
|
48
48
|
this._dfspId = config.dfspId;
|
|
49
49
|
this._expirySeconds = config.expirySeconds;
|
|
50
50
|
this._rejectTransfersOnExpiredQuotes = config.rejectTransfersOnExpiredQuotes;
|
|
@@ -59,7 +59,7 @@ class OutboundTransfersModel {
|
|
|
59
59
|
constructor(config) {
|
|
60
60
|
this._idGenerator = idGenerator(config.idGenerator);
|
|
61
61
|
this._cache = config.cache;
|
|
62
|
-
this._logger = config.logger.push({ component:
|
|
62
|
+
this._logger = config.logger.push({ component: this.constructor.name });
|
|
63
63
|
this._requestProcessingTimeoutSeconds = config.requestProcessingTimeoutSeconds;
|
|
64
64
|
this._dfspId = config.dfspId;
|
|
65
65
|
this._expirySeconds = config.expirySeconds;
|
|
@@ -37,7 +37,7 @@ const { buildUrl, HTTPResponseError } = require('./common');
|
|
|
37
37
|
class BackendRequests {
|
|
38
38
|
constructor(config) {
|
|
39
39
|
this.config = config;
|
|
40
|
-
this.logger = config.logger.push({ component:
|
|
40
|
+
this.logger = config.logger.push({ component: this.constructor.name });
|
|
41
41
|
this.requester = createHttpRequester({ logger: this.logger });
|
|
42
42
|
|
|
43
43
|
// FSPID of THIS DFSP
|
|
@@ -25,25 +25,8 @@
|
|
|
25
25
|
--------------
|
|
26
26
|
******/
|
|
27
27
|
|
|
28
|
-
const { hostname } = require('node:os');
|
|
29
28
|
const { randomBytes } = require('node:crypto');
|
|
30
|
-
const { WSO2Auth
|
|
31
|
-
|
|
32
|
-
const SDK_LOGGER_HIERARCHY = Logger.Logger.logLevels.reverse();
|
|
33
|
-
|
|
34
|
-
const createLogger = (conf) => new Logger.Logger({
|
|
35
|
-
context: {
|
|
36
|
-
// If we're running from a Mojaloop helm chart deployment, we'll have a SIM_NAME
|
|
37
|
-
simulator: process.env['SIM_NAME'],
|
|
38
|
-
hostname: hostname(),
|
|
39
|
-
},
|
|
40
|
-
opts: {
|
|
41
|
-
// todo: should be done inside Logger code
|
|
42
|
-
levels: SDK_LOGGER_HIERARCHY.slice(SDK_LOGGER_HIERARCHY.indexOf(conf.logLevel)),
|
|
43
|
-
isJsonOutput: conf.isJsonOutput,
|
|
44
|
-
},
|
|
45
|
-
stringify: Logger.buildStringify({ isJsonOutput: conf.isJsonOutput }),
|
|
46
|
-
});
|
|
29
|
+
const { WSO2Auth } = require('@mojaloop/sdk-standard-components');
|
|
47
30
|
|
|
48
31
|
const createAuthClient = (conf, logger) => {
|
|
49
32
|
const { wso2, outbound } = conf;
|
|
@@ -88,7 +71,6 @@ const generateTraceparent = (traceId = randomBytes(16).toString('hex')) => {
|
|
|
88
71
|
|
|
89
72
|
module.exports = {
|
|
90
73
|
createAuthClient,
|
|
91
|
-
createLogger,
|
|
92
74
|
generateTraceparent,
|
|
93
75
|
transformHeadersIsoToFspiop
|
|
94
76
|
};
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
jest.dontMock('redis');
|
|
32
32
|
|
|
33
33
|
const Cache = require('~/lib/cache');
|
|
34
|
-
const {
|
|
34
|
+
const { logger } = require('~/lib/logger');
|
|
35
35
|
const env = require('../testEnv');
|
|
36
36
|
|
|
37
37
|
const defaultCacheConfig = {
|
|
@@ -40,12 +40,7 @@ const defaultCacheConfig = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const createCache = async (config) => {
|
|
43
|
-
config.logger =
|
|
44
|
-
context: {
|
|
45
|
-
app: 'mojaloop-sdk-inboundCache'
|
|
46
|
-
},
|
|
47
|
-
stringify: Logger.buildStringify({ space: 4 }),
|
|
48
|
-
});
|
|
43
|
+
config.logger = logger.push({ context: { app: 'mojaloop-sdk-inboundCache' } });
|
|
49
44
|
const cache = new Cache(config);
|
|
50
45
|
await cache.connect();
|
|
51
46
|
|
|
@@ -26,9 +26,10 @@
|
|
|
26
26
|
******/
|
|
27
27
|
'use strict';
|
|
28
28
|
|
|
29
|
-
const fs = require('fs');
|
|
30
29
|
require('dotenv').config();
|
|
30
|
+
const fs = require('fs');
|
|
31
31
|
const { from } = require('env-var');
|
|
32
|
+
const { LOG_LEVELS } = require('../../../../src/lib/logger');
|
|
32
33
|
|
|
33
34
|
function getFileContent (path) {
|
|
34
35
|
if (!fs.existsSync(path)) {
|
|
@@ -43,7 +44,7 @@ const env = from(process.env, {
|
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
module.exports = {
|
|
46
|
-
logLevel: env.get('LOG_LEVEL').default('info').asEnum(
|
|
47
|
+
logLevel: env.get('LOG_LEVEL').default('info').asEnum(LOG_LEVELS),
|
|
47
48
|
server: {
|
|
48
49
|
port: env.get('SERVER_LISTEN_PORT').default('4005').asPortNumber(),
|
|
49
50
|
},
|
|
@@ -1,42 +1,36 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const { logger } = require('../../../../src/lib/logger');
|
|
1
3
|
const Config = require('./config');
|
|
2
4
|
const ManagementService = require('./server');
|
|
3
|
-
const { Logger } = require('@mojaloop/sdk-standard-components');
|
|
4
|
-
const express = require('express')
|
|
5
|
-
const app = express()
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
ctx: {
|
|
9
|
-
simulator: 'test',
|
|
10
|
-
hostname: 'test',
|
|
11
|
-
}
|
|
12
|
-
});
|
|
6
|
+
const app = express();
|
|
13
7
|
|
|
14
8
|
const managementServer = new ManagementService.Server({
|
|
15
9
|
port: Config.server.port,
|
|
16
|
-
logger
|
|
10
|
+
logger,
|
|
17
11
|
});
|
|
18
12
|
|
|
19
13
|
// Test API Server
|
|
20
14
|
app.use(express.json());
|
|
21
15
|
|
|
22
16
|
app.get('/health', (req, res) => {
|
|
23
|
-
|
|
24
|
-
})
|
|
17
|
+
res.send('OK');
|
|
18
|
+
});
|
|
25
19
|
|
|
26
20
|
app.post('/updateOutboundTLSConfig', (req, res) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
21
|
+
managementServer.updateOutboundTLSConfig(req.body);
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
message: 'Updated configuration'
|
|
24
|
+
});
|
|
25
|
+
});
|
|
32
26
|
|
|
33
27
|
app.post('/resetConfig', (req, res) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
28
|
+
managementServer.resetConfig();
|
|
29
|
+
res.status(200).json({
|
|
30
|
+
message: 'Reset Done'
|
|
31
|
+
});
|
|
32
|
+
});
|
|
39
33
|
|
|
40
34
|
app.listen(Config.testAPIServer.port, () => {
|
|
41
|
-
|
|
42
|
-
})
|
|
35
|
+
logger.log(`Test API Server listening on port ${Config.testAPIServer.port}`);
|
|
36
|
+
});
|