@mojaloop/bulk-api-adapter 17.1.6
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/.circleci/config.yml +11 -0
- package/.dockerignore +17 -0
- package/.editorconfig +10 -0
- package/.env +0 -0
- package/.gitattributes +2 -0
- package/.ncurc.yaml +5 -0
- package/.nvmrc +1 -0
- package/.nycrc.yml +20 -0
- package/.versionrc +15 -0
- package/API.md +2 -0
- package/CHANGELOG.md +257 -0
- package/CODEOWNERS +38 -0
- package/Dockerfile +44 -0
- package/LICENSE.md +10 -0
- package/README.md +40 -0
- package/audit-ci.jsonc +9 -0
- package/config/default.json +164 -0
- package/docker/bulk-api-adapter/default.json +147 -0
- package/docker/central-ledger/default.json +460 -0
- package/docker/kafka/scripts/provision.sh +42 -0
- package/docker/sql-init/01_permissions.sql +2 -0
- package/docker/wait-for/wait-for-bulk-api-adapter.sh +11 -0
- package/docker/wait-for/wait-for-central-ledger.sh +13 -0
- package/docker/wait-for/wait-for-kafka.sh +7 -0
- package/docker/wait-for/wait-for-mockserver.sh +20 -0
- package/docker/wait-for/wait-for-mysql.sh +11 -0
- package/docker/wait-for/wait-for-objstore.sh +7 -0
- package/docker/wait-for/wait-for.env +11 -0
- package/docker/wait-for/wait-for.sh +81 -0
- package/docker-compose.yml +167 -0
- package/jsdoc.json +38 -0
- package/package.json +152 -0
- package/sonar-project.properties +17 -0
- package/src/api/handlers/bulkTransfers/{id}/error.js +71 -0
- package/src/api/handlers/bulkTransfers/{id}.js +98 -0
- package/src/api/handlers/bulkTransfers.js +77 -0
- package/src/api/handlers/endpointcache.js +48 -0
- package/src/api/handlers/health.js +52 -0
- package/src/api/handlers/metrics.js +50 -0
- package/src/api/index.js +42 -0
- package/src/api/routes.js +42 -0
- package/src/domain/bulkTransfer/index.js +219 -0
- package/src/domain/participant/index.js +61 -0
- package/src/domain/participant/lib/cache/participantEndpoint.js +127 -0
- package/src/handlers/api/health/plugin.js +51 -0
- package/src/handlers/api/health/routes.js +42 -0
- package/src/handlers/api/metrics/handler.js +34 -0
- package/src/handlers/api/metrics/plugin.js +52 -0
- package/src/handlers/api/metrics/routes.js +43 -0
- package/src/handlers/index.js +82 -0
- package/src/handlers/notification/index.js +362 -0
- package/src/handlers/register.js +54 -0
- package/src/interface/swagger.yaml +672 -0
- package/src/lib/config.js +100 -0
- package/src/lib/headers.js +78 -0
- package/src/lib/healthCheck/subServiceHealth.js +88 -0
- package/src/models/participant/facade.js +61 -0
- package/src/models/participant/participantEndpoint.js +79 -0
- package/src/shared/plugins.js +111 -0
- package/src/shared/setup.js +204 -0
- package/test/fixtures/.gitkeep +0 -0
- package/test/functional/.gitkeep +0 -0
- package/test/helpers.js +79 -0
- package/test/integration/.gitkeep +0 -0
- package/test/unit/api/handlers/bulkTransfers/{id}/error.test.js +140 -0
- package/test/unit/api/handlers/bulkTransfers/{id}.test.js +209 -0
- package/test/unit/api/handlers/notification/index.test.js +252 -0
- package/test/unit/data/bulkTransfers/{id}/error.js +28 -0
- package/test/unit/data/bulkTransfers/{id}.js +49 -0
- package/test/unit/data/bulkTransfers.js +28 -0
- package/test/unit/data/metrics.js +28 -0
- package/test/unit/data/mockgen.js +13 -0
- package/test/unit/data/transfers/{id}/error.js +28 -0
- package/test/unit/domain/bulkTransfers/index.test.js +181 -0
- package/test/unit/endpointcache.test.js +52 -0
- package/test/unit/handlers/notification/handler.test.js +323 -0
- package/test/unit/health.test.js +75 -0
- package/test/unit/lib/config.test.js +83 -0
- package/test/unit/lib/headers.test.js +111 -0
- package/test/unit/metrics.test.js +71 -0
- package/test-integration.Dockerfile +24 -0
- package/test.Dockerfile +22 -0
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
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.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Mojaloop Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Mojaloop Foundation
|
|
19
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
20
|
+
|
|
21
|
+
* Georgi Georgiev <georgi.georgiev@modusbox.com> << central-services-shared
|
|
22
|
+
* Shashikant Hirugade <shashikant.hirugade@modusbox.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
const Logger = require('@mojaloop/central-services-logger')
|
|
29
|
+
const ErrorHandler = require('@mojaloop/central-services-error-handling')
|
|
30
|
+
const Config = require('../../../../lib/config')
|
|
31
|
+
const Catbox = require('@hapi/catbox')
|
|
32
|
+
const CatboxMemory = require('@hapi/catbox-memory')
|
|
33
|
+
const Model = require('../../../../models/participant/participantEndpoint')
|
|
34
|
+
const { Map } = require('immutable')
|
|
35
|
+
|
|
36
|
+
const partition = 'endpoint-cache'
|
|
37
|
+
const clientOptions = { partition }
|
|
38
|
+
const policyOptions = Config.ENDPOINT_CACHE_CONFIG
|
|
39
|
+
|
|
40
|
+
let client
|
|
41
|
+
let policy
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @module src/domain/participant/lib/cache
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @function initializeCache
|
|
49
|
+
*
|
|
50
|
+
* @description This initializes the cache for endpoints
|
|
51
|
+
*
|
|
52
|
+
* @returns {boolean} Returns true on successful initialization of the cache, throws error on falires
|
|
53
|
+
*/
|
|
54
|
+
const initializeCache = async () => {
|
|
55
|
+
Logger.info('participantEndpointCache::initializeCache::start')
|
|
56
|
+
try {
|
|
57
|
+
Logger.debug(`participantEndpointCache::initializeCache::start::clientOptions - ${clientOptions}`)
|
|
58
|
+
client = new Catbox.Client(CatboxMemory.Engine, clientOptions)
|
|
59
|
+
await client.start()
|
|
60
|
+
policyOptions.generateFunc = fetchEndpoints
|
|
61
|
+
Logger.debug(`participantEndpointCache::initializeCache::start::policyOptions - ${policyOptions}`)
|
|
62
|
+
policy = new Catbox.Policy(policyOptions, client, partition)
|
|
63
|
+
Logger.info('participantEndpointCache::initializeCache::Cache initialized successfully')
|
|
64
|
+
return true
|
|
65
|
+
} catch (err) {
|
|
66
|
+
Logger.error(`participantEndpointCache::Cache error:: ERROR:'${err}'`)
|
|
67
|
+
throw ErrorHandler.Factory.reformatFSPIOPError(err)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @function fetchEndpoints
|
|
73
|
+
*
|
|
74
|
+
* @description This populates the cache of endpoints
|
|
75
|
+
*
|
|
76
|
+
* @param {string} id The fsp id
|
|
77
|
+
* @returns {object} endpointMap Returns the object containing the endpoints for given fsp id
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
const fetchEndpoints = async (id) => {
|
|
81
|
+
Logger.debug(`[fsp=${id}] ~ participantEndpointCache::fetchEndpoints := Refreshing the cache for FSP: ${id}`)
|
|
82
|
+
|
|
83
|
+
const endpointMap = await Model.getEndpoint(id)
|
|
84
|
+
|
|
85
|
+
Logger.debug(`[fsp=${id}] ~ participantEndpointCache::fetchEndpoints := Returning the endpoints: ${JSON.stringify(endpointMap)}`)
|
|
86
|
+
return endpointMap
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @function GetEndpoint
|
|
91
|
+
*
|
|
92
|
+
* @description It returns the endpoint for a given fsp and type from the cache if the cache is still valid, otherwise it will refresh the cache and return the value
|
|
93
|
+
*
|
|
94
|
+
* @param {string} fsp - the id of the fsp
|
|
95
|
+
* @param {string} enpointType - the type of the endpoint
|
|
96
|
+
*
|
|
97
|
+
* @returns {string} - Returns the endpoint, throws error if failure occurs
|
|
98
|
+
*/
|
|
99
|
+
const getEndpoint = async (fsp, enpointType) => {
|
|
100
|
+
Logger.debug(`participantEndpointCache::getEndpoint::fsp - ${fsp}`)
|
|
101
|
+
Logger.debug(`participantEndpointCache::getEndpoint::enpointType - ${enpointType}`)
|
|
102
|
+
try {
|
|
103
|
+
const endpoints = await policy.get(fsp)
|
|
104
|
+
const url = new Map(endpoints).get(enpointType)
|
|
105
|
+
return url
|
|
106
|
+
} catch (err) {
|
|
107
|
+
Logger.error(`participantEndpointCache::getEndpoint:: ERROR:'${err}'`)
|
|
108
|
+
throw ErrorHandler.Factory.reformatFSPIOPError(err)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @function stopCache
|
|
114
|
+
*
|
|
115
|
+
* @description It stops the cache client
|
|
116
|
+
*
|
|
117
|
+
* @returns {boolean} - Returns the status
|
|
118
|
+
*/
|
|
119
|
+
const stopCache = async () => {
|
|
120
|
+
Logger.info('participantEndpointCache::stopCache::Stopping the cache')
|
|
121
|
+
return client.stop()
|
|
122
|
+
}
|
|
123
|
+
module.exports = {
|
|
124
|
+
initializeCache,
|
|
125
|
+
getEndpoint,
|
|
126
|
+
stopCache
|
|
127
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 organization 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
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
24
|
+
|
|
25
|
+
* Lazola Lucas <lazola.lucas@modusbox.com>
|
|
26
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
|
27
|
+
* Miguel de Barros <miguel.debarros@modusbox.com>
|
|
28
|
+
|
|
29
|
+
--------------
|
|
30
|
+
|
|
31
|
+
******/
|
|
32
|
+
'use strict'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @module src/handlers
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @function Register Handler Routes HAPI
|
|
40
|
+
*
|
|
41
|
+
* @async
|
|
42
|
+
* @description Registers registers plugins on HAPI server. This retrieves all routes to be exposed from the routes.js file
|
|
43
|
+
* @returns {Promise} - Returns a promise: resolve if successful, or rejection if failed
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
exports.plugin = {
|
|
47
|
+
name: 'handler routes',
|
|
48
|
+
register: function (server) {
|
|
49
|
+
server.route(require('./routes'))
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 organization 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
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
24
|
+
|
|
25
|
+
* ModusBox
|
|
26
|
+
- Miguel de Barros <miguel.debarros@modusbox.com>
|
|
27
|
+
- Steven Oderayi <steven.oderayi@modusbox.com>
|
|
28
|
+
|
|
29
|
+
--------------
|
|
30
|
+
******/
|
|
31
|
+
|
|
32
|
+
'use strict'
|
|
33
|
+
|
|
34
|
+
const healthHandler = require('../../../api/handlers/health')
|
|
35
|
+
|
|
36
|
+
module.exports = [
|
|
37
|
+
{
|
|
38
|
+
method: 'GET',
|
|
39
|
+
path: '/health',
|
|
40
|
+
handler: healthHandler.get
|
|
41
|
+
}
|
|
42
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
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.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Mojaloop Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Mojaloop Foundation
|
|
19
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
20
|
+
|
|
21
|
+
- Pedro Barreto <pedrob@crosslaketech.com>
|
|
22
|
+
- Rajiv Mothilal <rajivmothilal@gmail.com>
|
|
23
|
+
- Shashikant Hirugade <shashikant.hirugade@modusbox.com>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
const HTTPENUM = require('@mojaloop/central-services-shared').Enum.Http
|
|
30
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
|
31
|
+
|
|
32
|
+
exports.metrics = function (request, h) {
|
|
33
|
+
return h.response(Metrics.getMetricsForPrometheus()).code(HTTPENUM.ReturnCodes.OK.CODE)
|
|
34
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 organization 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
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
24
|
+
|
|
25
|
+
* Lazola Lucas <lazola.lucas@modusbox.com>
|
|
26
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
|
27
|
+
* Miguel de Barros <miguel.debarros@modusbox.com>
|
|
28
|
+
* Shashikant Hirugade <shashikant.hirugade@modusbox.com>
|
|
29
|
+
|
|
30
|
+
--------------
|
|
31
|
+
|
|
32
|
+
******/
|
|
33
|
+
'use strict'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @module src/handlers/api/plugin
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @function Register Handler Routes HAPI
|
|
41
|
+
*
|
|
42
|
+
* @async
|
|
43
|
+
* @description Registers registers plugins on HAPI server. This retrieves all routes to be exposed from the routes.js file
|
|
44
|
+
* @returns {Promise} - Returns a promise: resolve if successful, or rejection if failed
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
exports.plugin = {
|
|
48
|
+
name: 'handler metrics routes',
|
|
49
|
+
register: function (server) {
|
|
50
|
+
server.route(require('./routes'))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
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.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Mojaloop Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Mojaloop Foundation
|
|
19
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
20
|
+
|
|
21
|
+
- Pedro Barreto <pedrob@crosslaketech.com>
|
|
22
|
+
- Rajiv Mothilal <rajivmothilal@gmail.com>
|
|
23
|
+
- Shashikant Hirugade <shashikant.hirugade@modusbox.com>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
const Handler = require('./handler')
|
|
30
|
+
const tags = ['api', 'metrics']
|
|
31
|
+
|
|
32
|
+
module.exports = [
|
|
33
|
+
{
|
|
34
|
+
method: 'GET',
|
|
35
|
+
path: '/metrics',
|
|
36
|
+
handler: Handler.metrics,
|
|
37
|
+
config: {
|
|
38
|
+
tags,
|
|
39
|
+
description: 'Prometheus metrics endpoint',
|
|
40
|
+
id: 'metrics'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
@@ -0,0 +1,82 @@
|
|
|
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 organization 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
|
+
- Name Surname <name.surname@mojaloop.io>
|
|
24
|
+
|
|
25
|
+
* ModusBox
|
|
26
|
+
- Georgi Georgiev <georgi.georgiev@modusbox.com> << central-services-shared
|
|
27
|
+
- Miguel de Barros <miguel.debarros@modusbox.com>
|
|
28
|
+
--------------
|
|
29
|
+
******/
|
|
30
|
+
|
|
31
|
+
'use strict'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @module Handlers CLI Startup
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const Logger = require('@mojaloop/central-services-logger')
|
|
38
|
+
const Config = require('../lib/config')
|
|
39
|
+
const Setup = require('../shared/setup')
|
|
40
|
+
const PJson = require('../../package.json')
|
|
41
|
+
const HealthPlugin = require('./api/health/plugin')
|
|
42
|
+
const MetricsPlugin = require('./api/metrics/plugin')
|
|
43
|
+
const { Command } = require('commander')
|
|
44
|
+
|
|
45
|
+
const Program = new Command()
|
|
46
|
+
|
|
47
|
+
Program
|
|
48
|
+
.version(PJson.version)
|
|
49
|
+
.description('CLI to manage Handlers')
|
|
50
|
+
|
|
51
|
+
Program.command('handler') // sub-command name, coffeeType = type, required
|
|
52
|
+
.alias('h') // alternative sub-command is `h`
|
|
53
|
+
.description('Start a specified Handler') // command description
|
|
54
|
+
.option('--notification', 'Start the Notification Handler')
|
|
55
|
+
// function to execute when command is uses
|
|
56
|
+
.action(async (args) => {
|
|
57
|
+
const handlerList = []
|
|
58
|
+
if (args.notification && typeof args.notification === 'boolean') {
|
|
59
|
+
Logger.debug('CLI: Executing --notification')
|
|
60
|
+
const handler = {
|
|
61
|
+
type: 'notification',
|
|
62
|
+
enabled: true
|
|
63
|
+
}
|
|
64
|
+
handlerList.push(handler)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = Setup.initialize({
|
|
68
|
+
service: 'handler',
|
|
69
|
+
port: Config.PORT,
|
|
70
|
+
modules: [HealthPlugin, MetricsPlugin],
|
|
71
|
+
handlers: handlerList,
|
|
72
|
+
runHandlers: true
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
if (Array.isArray(process.argv) && process.argv.length > 2) {
|
|
77
|
+
// parse command line vars
|
|
78
|
+
Program.parse(process.argv)
|
|
79
|
+
} else {
|
|
80
|
+
// display default help
|
|
81
|
+
Program.help()
|
|
82
|
+
}
|