account-lookup-service 15.5.0-iso.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.circleci/config.yml +11 -0
- package/.ncurc.yaml +6 -0
- package/.nvmrc +1 -0
- package/.nycrc.yml +20 -0
- package/.versionrc +15 -0
- package/CHANGELOG.md +330 -0
- package/CODEOWNERS +38 -0
- package/Dockerfile +45 -0
- package/LICENSE.md +10 -0
- package/README.md +252 -0
- package/audit-ci.jsonc +32 -0
- package/audit-resolve.json +161 -0
- package/config/default.json +109 -0
- package/config/knexfile.js +21 -0
- package/docker/account-lookup-service/default.json +106 -0
- package/docker/account-lookup-service/make-default-json.sh +5 -0
- package/docker/account-lookup-service/override.json +15 -0
- package/docker/central-ledger/default.json +458 -0
- package/docker/config-modifier/account-lookup-service.js +31 -0
- package/docker/kafka/consumer.properties +26 -0
- package/docker/kafka/producer.properties +45 -0
- package/docker/kafka/server.properties +143 -0
- package/docker/kafka/tools-log4j.properties +21 -0
- package/docker/mock-proxy/Dockerfile +15 -0
- package/docker/mock-proxy/package-lock.json +4986 -0
- package/docker/mock-proxy/package.json +24 -0
- package/docker/mock-proxy/src/config.ts +14 -0
- package/docker/mock-proxy/src/server.ts +94 -0
- package/docker/mock-proxy/src/utils.ts +29 -0
- package/docker/mock-proxy/tsconfig.json +24 -0
- package/docker/sql-init/01_permissions.sql +2 -0
- package/docker/sql-init-central-ledger/01_permissions.sql +2 -0
- package/docker/wait-for/wait-for-account-lookup-service.sh +10 -0
- package/docker/wait-for/wait-for-central-ledger.sh +11 -0
- package/docker/wait-for/wait-for-kafka.sh +7 -0
- package/docker/wait-for/wait-for-ml-api-adapter.sh +9 -0
- package/docker/wait-for/wait-for-mockserver.sh +20 -0
- package/docker/wait-for/wait-for-mysql-als.sh +14 -0
- package/docker/wait-for/wait-for-mysql-central-ledger.sh +11 -0
- package/docker/wait-for/wait-for-mysql.sh +11 -0
- package/docker/wait-for/wait-for-objstore.sh +12 -0
- package/docker/wait-for/wait-for.env +18 -0
- package/docker/wait-for/wait-for.sh +81 -0
- package/docker-compose.integration.yml +29 -0
- package/docker-compose.yml +243 -0
- package/jest-int.config.js +8 -0
- package/jest.config.js +16 -0
- package/jsdoc.json +38 -0
- package/migrations/01_currency.js +42 -0
- package/migrations/02_endpointType.js +43 -0
- package/migrations/03_endpointType-indexes.js +37 -0
- package/migrations/04_partyIdType.js +43 -0
- package/migrations/05_partyIdType-indexes.js +38 -0
- package/migrations/08_oracleEndpoint.js +51 -0
- package/migrations/09_oracleEndpoint-indexes.js +41 -0
- package/migrations/10_oracleEndpoint-remove-constraints.js +38 -0
- package/package.json +180 -0
- package/scripts/_wait4_all.js +143 -0
- package/scripts/test-functional.sh +76 -0
- package/secrets/jwsSigningKey.key +27 -0
- package/seeds/currency.js +765 -0
- package/seeds/endpointType.js +65 -0
- package/seeds/partyIdType.js +79 -0
- package/src/api/endpointcache.js +67 -0
- package/src/api/health.js +66 -0
- package/src/api/index.js +85 -0
- package/src/api/oracles/{ID}.js +100 -0
- package/src/api/oracles.js +96 -0
- package/src/api/participants/{ID}/error.js +44 -0
- package/src/api/participants/{ID}.js +44 -0
- package/src/api/participants/{Type}/{ID}/error.js +74 -0
- package/src/api/participants/{Type}/{ID}/{SubId}/error.js +68 -0
- package/src/api/participants/{Type}/{ID}/{SubId}.js +113 -0
- package/src/api/participants/{Type}/{ID}.js +133 -0
- package/src/api/participants.js +63 -0
- package/src/api/parties/{Type}/{ID}/error.js +66 -0
- package/src/api/parties/{Type}/{ID}/{SubId}/error.js +56 -0
- package/src/api/parties/{Type}/{ID}/{SubId}.js +77 -0
- package/src/api/parties/{Type}/{ID}.js +98 -0
- package/src/api/routes.js +294 -0
- package/src/constants.js +16 -0
- package/src/domain/oracle/index.js +33 -0
- package/src/domain/oracle/oracle.js +234 -0
- package/src/domain/participants/index.js +35 -0
- package/src/domain/participants/participants.js +560 -0
- package/src/domain/parties/getPartiesByTypeAndID.js +239 -0
- package/src/domain/parties/index.js +32 -0
- package/src/domain/parties/parties.js +215 -0
- package/src/domain/parties/utils.js +84 -0
- package/src/domain/timeout/dto.js +48 -0
- package/src/domain/timeout/index.js +104 -0
- package/src/handlers/TimeoutHandler.js +94 -0
- package/src/handlers/index.js +70 -0
- package/src/handlers/monitoring/index.js +51 -0
- package/src/handlers/monitoring/plugins/health.js +61 -0
- package/src/handlers/monitoring/plugins/metrics.js +48 -0
- package/src/handlers/register.js +102 -0
- package/src/index.js +66 -0
- package/src/interface/admin-swagger.yaml +804 -0
- package/src/interface/admin_swagger.json +959 -0
- package/src/interface/api-swagger-iso20022-parties.yaml +1734 -0
- package/src/interface/api-swagger.yaml +1733 -0
- package/src/interface/api_swagger.json +3046 -0
- package/src/interface/fspiop-rest-v2.0-ISO20022_parties.yaml +2256 -0
- package/src/interface/thirdparty/admin-swagger.yaml +808 -0
- package/src/interface/thirdparty/admin_swagger.json +961 -0
- package/src/interface/thirdparty/api-swagger.yaml +1739 -0
- package/src/interface/thirdparty/api_swagger.json +3142 -0
- package/src/lib/argv.js +39 -0
- package/src/lib/cache.js +126 -0
- package/src/lib/config.js +183 -0
- package/src/lib/db.js +26 -0
- package/src/lib/headers.js +53 -0
- package/src/lib/healthCheck/subServiceHealth.js +84 -0
- package/src/lib/index.js +11 -0
- package/src/lib/migrator.js +17 -0
- package/src/lib/requestLogger.js +54 -0
- package/src/lib/util.js +66 -0
- package/src/metrics/handler.js +33 -0
- package/src/metrics/plugin.js +52 -0
- package/src/metrics/routes.js +43 -0
- package/src/models/currency/currency.js +48 -0
- package/src/models/currency/index.js +32 -0
- package/src/models/endpointType/endpointType.js +48 -0
- package/src/models/endpointType/index.js +32 -0
- package/src/models/misc/migrationLock.js +49 -0
- package/src/models/oracle/facade.js +341 -0
- package/src/models/oracle/index.js +41 -0
- package/src/models/oracle/oracleEndpoint.js +192 -0
- package/src/models/oracle/oracleEndpointCached.js +108 -0
- package/src/models/participantEndpoint/facade.js +238 -0
- package/src/models/partyIdType/index.js +32 -0
- package/src/models/partyIdType/partyIdType.js +41 -0
- package/src/plugins.js +139 -0
- package/src/server.js +199 -0
- package/test/fixtures/index.js +131 -0
- package/test/fixtures/iso.js +110 -0
- package/test/integration/.env +8 -0
- package/test/integration/api/parties.test.js +137 -0
- package/test/integration/constants.js +20 -0
- package/test/integration/domain/oracle/index.test.js +324 -0
- package/test/integration/domain/timeout/index.test.js +75 -0
- package/test/integration/env.sh +15 -0
- package/test/integration/example.test.js +12 -0
- package/test/integration/models/currency/currency.test.js +68 -0
- package/test/integration/plugins.test.js +62 -0
- package/test/integration/prepareTestParticipants.js +30 -0
- package/test/integration/setup.js +5 -0
- package/test/integration-config.json +81 -0
- package/test/integration-runner.sh +108 -0
- package/test/unit/api/health.test.js +142 -0
- package/test/unit/api/oracles/{ID}.test.js +264 -0
- package/test/unit/api/oracles.test.js +173 -0
- package/test/unit/api/participants/participants.test.js +117 -0
- package/test/unit/api/participants/{Type}/{ID}/error.test.js +155 -0
- package/test/unit/api/participants/{Type}/{ID}/{SubId}/error.test.js +131 -0
- package/test/unit/api/participants/{Type}/{ID}/{SubId}.test.js +377 -0
- package/test/unit/api/participants/{Type}/{ID}.test.js +383 -0
- package/test/unit/api/participants.test.js +108 -0
- package/test/unit/api/parties/endpointcache.test.js +83 -0
- package/test/unit/api/parties/parties.test.js +102 -0
- package/test/unit/api/parties/{Type}/{ID}/error.test.js +145 -0
- package/test/unit/api/parties/{Type}/{ID}/{SubId}/error.test.js +141 -0
- package/test/unit/api/parties/{Type}/{ID}/{SubId}.test.js +241 -0
- package/test/unit/api/parties/{Type}/{ID}.test.js +240 -0
- package/test/unit/domain/oracle/oracle.test.js +505 -0
- package/test/unit/domain/participants/participants.test.js +1724 -0
- package/test/unit/domain/parties/parties.test.js +940 -0
- package/test/unit/domain/timeout/dto.test.js +28 -0
- package/test/unit/domain/timeout/index.test.js +81 -0
- package/test/unit/handlers/TimeoutHandler.test.js +125 -0
- package/test/unit/handlers/index.test.js +56 -0
- package/test/unit/handlers/register.test.js +90 -0
- package/test/unit/index.test.js +139 -0
- package/test/unit/iso20022/partiesValidation.test.js +129 -0
- package/test/unit/lib/TransformFacades.test.js +18 -0
- package/test/unit/lib/argv.test.js +40 -0
- package/test/unit/lib/cache.test.js +172 -0
- package/test/unit/lib/config.test.js +108 -0
- package/test/unit/lib/healthCheck/subServiceHealth.test.js +89 -0
- package/test/unit/lib/migrator.test.js +52 -0
- package/test/unit/lib/requestLogger.test.js +115 -0
- package/test/unit/lib/util.test.js +68 -0
- package/test/unit/mocks.js +66 -0
- package/test/unit/models/currency/currency.test.js +91 -0
- package/test/unit/models/endpointType/endpointType.test.js +69 -0
- package/test/unit/models/misc/migrationLock.test.js +96 -0
- package/test/unit/models/oracle/facade.test.js +546 -0
- package/test/unit/models/oracle/oracleEndpoint.test.js +409 -0
- package/test/unit/models/oracle/oracleEndpointCached.test.js +153 -0
- package/test/unit/models/participantEndpoint/facade.test.js +295 -0
- package/test/unit/models/partyIdType/partyIdType.test.js +88 -0
- package/test/unit/plugins.test.js +89 -0
- package/test/unit/setup.js +7 -0
- package/test/util/apiClients/AlsApiClient.js +44 -0
- package/test/util/apiClients/BasicApiClient.js +34 -0
- package/test/util/apiClients/ProxyApiClient.js +25 -0
- package/test/util/apiClients/index.js +7 -0
- package/test/util/helper.js +332 -0
- package/test/util/index.js +11 -0
- package/test/util/mockgen.js +43 -0
- package/test/util/onboarding.js +132 -0
- package/test/util/scripts/addAlsDb.sh +33 -0
- package/test/util/scripts/configureMockServer.sh +35 -0
- package/test/util/scripts/env.sh +19 -0
- package/test/util/scripts/populateTestData.sh +62 -0
- package/test/util/scripts/startMockCentralServer.sh +45 -0
- package/test/util/scripts/startMockOracleServer.sh +45 -0
- package/test/util/testConfig.js +44 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
- Juan Correa <juan.correa@modusbox.com>
|
23
|
+
|
24
|
+
--------------
|
25
|
+
******/
|
26
|
+
'use strict'
|
27
|
+
|
28
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
29
|
+
const ErrorHandler = require('@mojaloop/central-services-error-handling')
|
30
|
+
const EventSdk = require('@mojaloop/event-sdk')
|
31
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
32
|
+
const LibUtil = require('../../../../lib/util')
|
33
|
+
const participants = require('../../../../domain/participants')
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Operations on /participants/{Type}/{ID}/error
|
37
|
+
*/
|
38
|
+
module.exports = {
|
39
|
+
/**
|
40
|
+
* summary: ParticipantsErrorByTypeAndID
|
41
|
+
* description: If the server is unable to find, create or delete the associated FSP of the provided identity, or another processing error occurred, the error callback PUT /participants/<Type>/<ID>/error (or PUT /participants/<Type>/<ID>/<SubId>/error) is used.
|
42
|
+
* parameters: Type, ID, body, Content-Length, Content-Type, Date, X-Forwarded-For, FSPIOP-Source, FSPIOP-Destination, FSPIOP-Encryption, FSPIOP-Signature, FSPIOP-URI, FSPIOP-HTTP-Method
|
43
|
+
* produces: application/json
|
44
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
45
|
+
*/
|
46
|
+
put: async (context, request, h) => {
|
47
|
+
const histTimerEnd = Metrics.getHistogram(
|
48
|
+
'ing_putParticipantsErrorByTypeAndID',
|
49
|
+
'Ingress: Put participant error by Type and Id',
|
50
|
+
['success']
|
51
|
+
).startTimer()
|
52
|
+
const span = request.span
|
53
|
+
const spanTags = LibUtil.getSpanTags(request, Enum.Events.Event.Type.PARTICIPANT, Enum.Events.Event.Action.PUT)
|
54
|
+
span.setTags(spanTags)
|
55
|
+
const metadata = `${request.method} ${request.path}`
|
56
|
+
try {
|
57
|
+
await span.audit({
|
58
|
+
headers: request.headers,
|
59
|
+
payload: request.payload
|
60
|
+
}, EventSdk.AuditEventAction.start)
|
61
|
+
request.server.log(['info'], `received: ${metadata}. ${LibUtil.getStackOrInspect(request.params)}`)
|
62
|
+
participants.putParticipantsErrorByTypeAndID(request.headers, request.params, request.payload, request.dataUri, span).catch(err => {
|
63
|
+
request.server.log(['error'], `ERROR - putParticipantsErrorByTypeAndID:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
64
|
+
})
|
65
|
+
request.server.log(['info'], `success: ${metadata}.`)
|
66
|
+
histTimerEnd({ success: true })
|
67
|
+
} catch (err) {
|
68
|
+
request.server.log(['error'], `ERROR - ${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
69
|
+
histTimerEnd({ success: false })
|
70
|
+
throw ErrorHandler.Factory.reformatFSPIOPError(err)
|
71
|
+
}
|
72
|
+
return h.response().code(200)
|
73
|
+
}
|
74
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
* Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
* Steven Oderayi <steven.oderayi@modusbox.com>
|
23
|
+
|
24
|
+
--------------
|
25
|
+
******/
|
26
|
+
|
27
|
+
'use strict'
|
28
|
+
|
29
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
30
|
+
const ErrorHandler = require('@mojaloop/central-services-error-handling')
|
31
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
32
|
+
const participants = require('../../../../../domain/participants')
|
33
|
+
const LibUtil = require('../../../../../lib/util')
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Operations on /participants/{Type}/{ID}/{SubId}/error
|
37
|
+
*/
|
38
|
+
module.exports = {
|
39
|
+
/**
|
40
|
+
* summary: ParticipantsSubIdErrorByTypeAndID
|
41
|
+
* description: If the server is unable to find, create or delete the associated FSP of the provided identity, or another processing error occurred, the error callback PUT /participants/<Type>/<ID>/error (or PUT /participants/<Type>/<ID>/<SubId>/error) is used.
|
42
|
+
* parameters: Type, ID, SubId, body, Content-Length, Content-Type, Date, X-Forwarded-For, FSPIOP-Source, FSPIOP-Destination, FSPIOP-Encryption, FSPIOP-Signature, FSPIOP-URI, FSPIOP-HTTP-Method
|
43
|
+
* produces: application/json
|
44
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
45
|
+
*/
|
46
|
+
put: async (context, request, h) => {
|
47
|
+
const histTimerEnd = Metrics.getHistogram(
|
48
|
+
'ing_putParticipantsErrorByTypeIDAndSubID',
|
49
|
+
'Ingress: Put participant error by Type, Id, and SubId',
|
50
|
+
['success']
|
51
|
+
).startTimer()
|
52
|
+
const metadata = `${request.method} ${request.path}`
|
53
|
+
try {
|
54
|
+
request.server.log(['info'], `received: ${metadata}. ${LibUtil.getStackOrInspect(request.params)}`)
|
55
|
+
// await participants.putParticipantsErrorByTypeAndID(request.headers, request.params, request.payload, request.dataUri)
|
56
|
+
participants.putParticipantsErrorByTypeAndID(request.headers, request.params, request.payload, request.dataUri).catch(err => {
|
57
|
+
request.server.log(['error'], `ERROR - deleteParticipants:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
58
|
+
})
|
59
|
+
request.server.log(['info'], `success: ${metadata}.`)
|
60
|
+
histTimerEnd({ success: true })
|
61
|
+
} catch (err) {
|
62
|
+
request.server.log(['error'], `ERROR - ${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
63
|
+
histTimerEnd({ success: false })
|
64
|
+
throw ErrorHandler.Factory.reformatFSPIOPError(err)
|
65
|
+
}
|
66
|
+
return h.response().code(Enum.Http.ReturnCodes.OK.CODE)
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
* Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
* Steven Oderayi <steven.oerayi@modusbox.com>
|
23
|
+
|
24
|
+
--------------
|
25
|
+
******/
|
26
|
+
'use strict'
|
27
|
+
|
28
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
29
|
+
const LibUtil = require('../../../../lib/util')
|
30
|
+
const participants = require('../../../../domain/participants')
|
31
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Operations on /participants/{Type}/{ID}/{SubId}
|
35
|
+
*/
|
36
|
+
module.exports = {
|
37
|
+
/**
|
38
|
+
* summary: ParticipantsSubIdByTypeAndID
|
39
|
+
* description: The HTTP request GET /participants/<Type>/<ID> (or GET /participants/<Type>/<ID>/<SubId>) is used to find out in which FSP the requested Party, defined by <Type>, <ID> and optionally <SubId>, is located (for example, GET /participants/MSISDN/123456789, or GET /participants/BUSINESS/shoecompany/employee1). This HTTP request should support a query string for filtering of currency. To use filtering of currency, the HTTP request GET /participants/<Type>/<ID>?currency=XYZ should be used, where XYZ is the requested currency.
|
40
|
+
* parameters: Accept
|
41
|
+
* produces: application/json
|
42
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
43
|
+
*/
|
44
|
+
get: async (context, request, h) => {
|
45
|
+
const histTimerEnd = Metrics.getHistogram(
|
46
|
+
'ing_getParticipantsByTypeIdAndSubID',
|
47
|
+
'Ingress: Get participant by Type, ID and SubId',
|
48
|
+
['success']
|
49
|
+
).startTimer()
|
50
|
+
participants.getParticipantsByTypeAndID(request.headers, request.params, request.method, request.query, request.span, request.server.app.cache).catch(err => {
|
51
|
+
request.server.log(['error'], `ERROR - getParticipantsByTypeAndID: ${LibUtil.getStackOrInspect(err)}`)
|
52
|
+
})
|
53
|
+
histTimerEnd({ success: true })
|
54
|
+
return h.response().code(Enum.Http.ReturnCodes.ACCEPTED.CODE)
|
55
|
+
},
|
56
|
+
/**
|
57
|
+
* summary: ParticipantsSubIdByTypeAndID
|
58
|
+
* description: The callback PUT /participants/<Type>/<ID> (or PUT /participants/<Type>/<ID>/<SubId>) is used to inform the client of a successful result of the lookup, creation, or deletion of the FSP information related to the Party. If the FSP information is deleted, the fspId element should be empty; otherwise the element should include the FSP information for the Party.
|
59
|
+
* parameters: body, Content-Length
|
60
|
+
* produces: application/json
|
61
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
62
|
+
*/
|
63
|
+
put: async (context, request, h) => {
|
64
|
+
const histTimerEnd = Metrics.getHistogram(
|
65
|
+
'ing_putParticipantsByTypeIDAndSubID',
|
66
|
+
'Ingress: Put participant by Type, ID and SubId',
|
67
|
+
['success']
|
68
|
+
).startTimer()
|
69
|
+
participants.putParticipantsByTypeAndID(request.headers, request.params, request.method, request.payload, request.server.app.cache).catch(err => {
|
70
|
+
request.server.log(['error'], `ERROR - putParticipantsByTypeAndID: ${LibUtil.getStackOrInspect(err)}`)
|
71
|
+
})
|
72
|
+
histTimerEnd({ success: true })
|
73
|
+
return h.response().code(Enum.Http.ReturnCodes.OK.CODE)
|
74
|
+
},
|
75
|
+
/**
|
76
|
+
* summary: ParticipantsSubIdByTypeAndID
|
77
|
+
* description: The HTTP request POST /participants/<Type>/<ID> (or POST /participants/<Type>/<ID>/<SubId>) is used to create information in the server regarding the provided identity, defined by <Type>, <ID>, and optionally <SubId> (for example, POST /participants/MSISDN/123456789 or POST /participants/BUSINESS/shoecompany/employee1).
|
78
|
+
* parameters: body, Accept, Content-Length
|
79
|
+
* produces: application/json
|
80
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
81
|
+
*/
|
82
|
+
post: async (context, request, h) => {
|
83
|
+
const histTimerEnd = Metrics.getHistogram(
|
84
|
+
'ing_postParticipantsByTypeIDAndSubID',
|
85
|
+
'Ingress: Post participant by Type, ID and SubId',
|
86
|
+
['success']
|
87
|
+
).startTimer()
|
88
|
+
participants.postParticipants(request.headers, request.method, request.params, request.payload, request.span, request.server.app.cache).catch(err => {
|
89
|
+
request.server.log(['error'], `ERROR - postParticipants: ${LibUtil.getStackOrInspect(err)}`)
|
90
|
+
})
|
91
|
+
histTimerEnd({ success: true })
|
92
|
+
return h.response().code(Enum.Http.ReturnCodes.ACCEPTED.CODE)
|
93
|
+
},
|
94
|
+
/**
|
95
|
+
* summary: ParticipantsSubIdByTypeAndID
|
96
|
+
* description: The HTTP request DELETE /participants/<Type>/<ID> (or DELETE /participants/<Type>/<ID>/<SubId>) is used to delete information in the server regarding the provided identity, defined by <Type> and <ID>) (for example, DELETE /participants/MSISDN/123456789), and optionally <SubId>. This HTTP request should support a query string to delete FSP information regarding a specific currency only. To delete a specific currency only, the HTTP request DELETE /participants/<Type>/<ID>?currency=XYZ should be used, where XYZ is the requested currency. Note - The Account Lookup System should verify that it is the Party’s current FSP that is deleting the FSP information.
|
97
|
+
* parameters: Accept
|
98
|
+
* produces: application/json
|
99
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
100
|
+
*/
|
101
|
+
delete: async (context, request, h) => {
|
102
|
+
const histTimerEnd = Metrics.getHistogram(
|
103
|
+
'ing_deleteParticipantsByTypeIDAndSubID',
|
104
|
+
'Ingress: Delete participant by Type, ID and SubId',
|
105
|
+
['success']
|
106
|
+
).startTimer()
|
107
|
+
participants.deleteParticipants(request.headers, request.params, request.method, request.query, request.server.app.cache).catch(err => {
|
108
|
+
request.server.log(['error'], `ERROR - deleteParticipants: ${LibUtil.getStackOrInspect(err)}`)
|
109
|
+
})
|
110
|
+
histTimerEnd({ success: true })
|
111
|
+
return h.response().code(Enum.Http.ReturnCodes.ACCEPTED.CODE)
|
112
|
+
}
|
113
|
+
}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
* Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
* Juan Correa <juan.correa@modusbox.com>
|
23
|
+
|
24
|
+
--------------
|
25
|
+
******/
|
26
|
+
'use strict'
|
27
|
+
|
28
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
29
|
+
const EventSdk = require('@mojaloop/event-sdk')
|
30
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
31
|
+
const LibUtil = require('../../../lib/util')
|
32
|
+
const participants = require('../../../domain/participants')
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Operations on /participants/{Type}/{ID}
|
36
|
+
*/
|
37
|
+
module.exports = {
|
38
|
+
/**
|
39
|
+
* summary: ParticipantsByTypeAndID
|
40
|
+
* description: The HTTP request GET /participants/<Type>/<ID> (or GET /participants/<Type>/<ID>/<SubId>) is used to find out in which FSP the requested Party, defined by <Type>, <ID> and optionally <SubId>, is located (for example, GET /participants/MSISDN/123456789, or GET /participants/BUSINESS/shoecompany/employee1). This HTTP request should support a query string for filtering of currency. To use filtering of currency, the HTTP request GET /participants/<Type>/<ID>?currency=XYZ should be used, where XYZ is the requested currency.
|
41
|
+
* parameters: Accept
|
42
|
+
* produces: application/json
|
43
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
44
|
+
*/
|
45
|
+
get: async function (context, request, h) {
|
46
|
+
const histTimerEnd = Metrics.getHistogram(
|
47
|
+
'ing_getParticipantsByTypeAndID',
|
48
|
+
'Ingress: Get participant by Type and Id',
|
49
|
+
['success']
|
50
|
+
).startTimer()
|
51
|
+
const span = request.span
|
52
|
+
const spanTags = LibUtil.getSpanTags(request, Enum.Events.Event.Type.PARTICIPANT, Enum.Events.Event.Action.LOOKUP)
|
53
|
+
span.setTags(spanTags)
|
54
|
+
await span.audit({
|
55
|
+
headers: request.headers,
|
56
|
+
payload: request.payload
|
57
|
+
}, EventSdk.AuditEventAction.start)
|
58
|
+
const metadata = `${request.method} ${request.path}`
|
59
|
+
participants.getParticipantsByTypeAndID(request.headers, request.params, request.method, request.query, span, request.server.app.cache).catch(err => {
|
60
|
+
request.server.log(['error'], `ERROR - getParticipantsByTypeAndID:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
61
|
+
})
|
62
|
+
histTimerEnd({ success: true })
|
63
|
+
|
64
|
+
return h.response().code(202)
|
65
|
+
},
|
66
|
+
/**
|
67
|
+
* summary: ParticipantsByTypeAndID
|
68
|
+
* description: The callback PUT /participants/<Type>/<ID> (or PUT /participants/<Type>/<ID>/<SubId>) is used to inform the client of a successful result of the lookup, creation, or deletion of the FSP information related to the Party. If the FSP information is deleted, the fspId element should be empty; otherwise the element should include the FSP information for the Party.
|
69
|
+
* parameters: body, Content-Length
|
70
|
+
* produces: application/json
|
71
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
72
|
+
*/
|
73
|
+
put: async function (context, request, h) {
|
74
|
+
const histTimerEnd = Metrics.getHistogram(
|
75
|
+
'ing_putParticipantsByTypeAndID',
|
76
|
+
'Ingress: Put participant by Type and Id',
|
77
|
+
['success']
|
78
|
+
).startTimer()
|
79
|
+
const metadata = `${request.method} ${request.path}`
|
80
|
+
participants.putParticipantsByTypeAndID(request.headers, request.params, request.method, request.payload, request.server.app.cache).catch(err => {
|
81
|
+
request.server.log(['error'], `ERROR - putParticipantsByTypeAndID:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
82
|
+
})
|
83
|
+
histTimerEnd({ success: true })
|
84
|
+
return h.response().code(200)
|
85
|
+
},
|
86
|
+
/**
|
87
|
+
* summary: ParticipantsByIDAndType
|
88
|
+
* description: The HTTP request POST /participants/<Type>/<ID> (or POST /participants/<Type>/<ID>/<SubId>) is used to create information in the server regarding the provided identity, defined by <Type>, <ID>, and optionally <SubId> (for example, POST /participants/MSISDN/123456789 or POST /participants/BUSINESS/shoecompany/employee1).
|
89
|
+
* parameters: body, Accept, Content-Length
|
90
|
+
* produces: application/json
|
91
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
92
|
+
*/
|
93
|
+
post: async function (context, request, h) {
|
94
|
+
const histTimerEnd = Metrics.getHistogram(
|
95
|
+
'ing_postParticipantsbyTypeAndID',
|
96
|
+
'Ingress: Post participant by Type and Id',
|
97
|
+
['success']
|
98
|
+
).startTimer()
|
99
|
+
const span = request.span
|
100
|
+
const spanTags = LibUtil.getSpanTags(request, Enum.Events.Event.Type.PARTICIPANT, Enum.Events.Event.Action.POST)
|
101
|
+
span.setTags(spanTags)
|
102
|
+
await span.audit({
|
103
|
+
headers: request.headers,
|
104
|
+
payload: request.payload
|
105
|
+
}, EventSdk.AuditEventAction.start)
|
106
|
+
const metadata = `${request.method} ${request.path}`
|
107
|
+
participants.postParticipants(request.headers, request.method, request.params, request.payload, span, request.server.app.cache).catch(err => {
|
108
|
+
request.server.log(['error'], `ERROR - postParticipants:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
109
|
+
})
|
110
|
+
histTimerEnd({ success: true })
|
111
|
+
return h.response().code(202)
|
112
|
+
},
|
113
|
+
/**
|
114
|
+
* summary: ParticipantsByTypeAndID
|
115
|
+
* description: The HTTP request DELETE /participants/<Type>/<ID> (or DELETE /participants/<Type>/<ID>/<SubId>) is used to delete information in the server regarding the provided identity, defined by <Type> and <ID>) (for example, DELETE /participants/MSISDN/123456789), and optionally <SubId>. This HTTP request should support a query string to delete FSP information regarding a specific currency only. To delete a specific currency only, the HTTP request DELETE /participants/<Type>/<ID>?currency=XYZ should be used, where XYZ is the requested currency. Note - The Account Lookup System should verify that it is the Party’s current FSP that is deleting the FSP information.
|
116
|
+
* parameters: Accept
|
117
|
+
* produces: application/json
|
118
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
119
|
+
*/
|
120
|
+
delete: async function (context, request, h) {
|
121
|
+
const histTimerEnd = Metrics.getHistogram(
|
122
|
+
'ing_deleteParticipantsByTypeAndID',
|
123
|
+
'Ingress: Delete participant by Type and Id',
|
124
|
+
['success']
|
125
|
+
).startTimer()
|
126
|
+
const metadata = `${request.method} ${request.path}`
|
127
|
+
participants.deleteParticipants(request.headers, request.params, request.method, request.query, request.server.app.cache).catch(err => {
|
128
|
+
request.server.log(['error'], `ERROR - deleteParticipants:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
|
129
|
+
})
|
130
|
+
histTimerEnd({ success: true })
|
131
|
+
return h.response().code(202)
|
132
|
+
}
|
133
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
|
23
|
+
--------------
|
24
|
+
*****/
|
25
|
+
'use strict'
|
26
|
+
|
27
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
28
|
+
const EventSdk = require('@mojaloop/event-sdk')
|
29
|
+
const LibUtil = require('../lib/util')
|
30
|
+
const participants = require('../domain/participants')
|
31
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Operations on /participants
|
35
|
+
*/
|
36
|
+
module.exports = {
|
37
|
+
/**
|
38
|
+
* summary: Participants
|
39
|
+
* description: The HTTP request POST /participants is used to create information in the server regarding the provided list of identities. This request should be used for bulk creation of FSP information for more than one Party. The optional currency parameter should indicate that each provided Party supports the currency
|
40
|
+
* parameters: body, Accept, Content-Length, Content-Type, Date, X-Forwarded-For, FSPIOP-Source, FSPIOP-Destination, FSPIOP-Encryption, FSPIOP-Signature, FSPIOP-URI, FSPIOP-HTTP-Method
|
41
|
+
* produces: application/json
|
42
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
43
|
+
*/
|
44
|
+
post: async function (context, request, h) {
|
45
|
+
const histTimerEnd = Metrics.getHistogram(
|
46
|
+
'ing_postParticipantsBatch',
|
47
|
+
'Ingress: Post participants batch',
|
48
|
+
['success']
|
49
|
+
).startTimer()
|
50
|
+
const span = request.span
|
51
|
+
const spanTags = LibUtil.getSpanTags(request, Enum.Events.Event.Type.PARTICIPANT, Enum.Events.Event.Action.POST)
|
52
|
+
span.setTags(spanTags)
|
53
|
+
await span.audit({
|
54
|
+
headers: request.headers,
|
55
|
+
payload: request.payload
|
56
|
+
}, EventSdk.AuditEventAction.start)
|
57
|
+
// Here we call an async function- but as we send an immediate sync response, _all_ errors
|
58
|
+
// _must_ be handled by postParticipantsBatch.
|
59
|
+
participants.postParticipantsBatch(request.headers, request.method, request.payload, span)
|
60
|
+
histTimerEnd({ success: true })
|
61
|
+
return h.response().code(200)
|
62
|
+
}
|
63
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
* Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
|
23
|
+
--------------
|
24
|
+
******/
|
25
|
+
'use strict'
|
26
|
+
|
27
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
28
|
+
const EventSdk = require('@mojaloop/event-sdk')
|
29
|
+
const LibUtil = require('../../../../lib/util')
|
30
|
+
const parties = require('../../../../domain/parties')
|
31
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Operations on /parties/{Type}/{ID}/error
|
35
|
+
*/
|
36
|
+
module.exports = {
|
37
|
+
/**
|
38
|
+
* summary: PartiesErrorByTypeAndID
|
39
|
+
* description: If the server is unable to find Party information of the provided identity, or another processing error occurred, the error callback PUT /parties/<Type>/<ID>/error (or PUT /parties/<Type>/<ID>/<SubId>/error) is used.
|
40
|
+
* parameters: Type, ID, body, Content-Length, Content-Type, Date, X-Forwarded-For, FSPIOP-Source, FSPIOP-Destination, FSPIOP-Encryption, FSPIOP-Signature, FSPIOP-URI, FSPIOP-HTTP-Method
|
41
|
+
* produces: application/json
|
42
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
43
|
+
*/
|
44
|
+
put: async function (context, request, h) {
|
45
|
+
const histTimerEnd = Metrics.getHistogram(
|
46
|
+
'ing_putPartiesErrorByTypeAndID',
|
47
|
+
'Ingress - Put parties error by Type and Id',
|
48
|
+
['success']
|
49
|
+
).startTimer()
|
50
|
+
const { headers, payload, params, dataUri, span } = request
|
51
|
+
const { cache, proxyCache } = request.server.app
|
52
|
+
|
53
|
+
const spanTags = LibUtil.getSpanTags(request, Enum.Events.Event.Type.PARTY, Enum.Events.Event.Action.PUT)
|
54
|
+
span.setTags(spanTags)
|
55
|
+
await span.audit({
|
56
|
+
headers,
|
57
|
+
payload
|
58
|
+
}, EventSdk.AuditEventAction.start)
|
59
|
+
|
60
|
+
parties.putPartiesErrorByTypeAndID(headers, params, payload, dataUri, span, cache, proxyCache).catch(err => {
|
61
|
+
request.server.log(['error'], `ERROR - putPartiesErrorByTypeAndID: ${LibUtil.getStackOrInspect(err)}`)
|
62
|
+
})
|
63
|
+
histTimerEnd({ success: true })
|
64
|
+
return h.response().code(200)
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
* Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
|
23
|
+
--------------
|
24
|
+
******/
|
25
|
+
'use strict'
|
26
|
+
|
27
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
28
|
+
const LibUtil = require('../../../../../lib/util')
|
29
|
+
const parties = require('../../../../../domain/parties')
|
30
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Operations on /parties/{Type}/{ID}/{SubId}/error
|
34
|
+
*/
|
35
|
+
module.exports = {
|
36
|
+
/**
|
37
|
+
* summary: PartiesSubIdErrorByTypeAndID
|
38
|
+
* description: If the server is unable to find Party information of the provided identity, or another processing error occurred, the error callback PUT /parties/<Type>/<ID>/error (or PUT /parties/<Type>/<ID>/<SubId>/error) is used.
|
39
|
+
* parameters: Type, ID, SubId, body, Content-Length, Content-Type, Date, X-Forwarded-For, FSPIOP-Source, FSPIOP-Destination, FSPIOP-Encryption, FSPIOP-Signature, FSPIOP-URI, FSPIOP-HTTP-Method
|
40
|
+
* produces: application/json
|
41
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
42
|
+
*/
|
43
|
+
put: function (context, request, h) {
|
44
|
+
const histTimerEnd = Metrics.getHistogram(
|
45
|
+
'ing_putPartiesErrorByTypeIDAndSubID',
|
46
|
+
'Ingress - Put parties error by Type, ID and SubId',
|
47
|
+
['success']
|
48
|
+
).startTimer()
|
49
|
+
const { cache, proxyCache } = request.server.app
|
50
|
+
parties.putPartiesErrorByTypeAndID(request.headers, request.params, request.payload, request.dataUri, request.span, cache, proxyCache).catch(err => {
|
51
|
+
request.server.log(['error'], `ERROR - putPartiesErrorByTypeAndID: ${LibUtil.getStackOrInspect(err)}`)
|
52
|
+
})
|
53
|
+
histTimerEnd({ success: true })
|
54
|
+
return h.response().code(Enum.Http.ReturnCodes.OK.CODE)
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates 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
|
+
Gates 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
|
+
* Gates Foundation
|
19
|
+
* Name Surname <name.surname@gatesfoundation.com>
|
20
|
+
|
21
|
+
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
|
22
|
+
* Steven Oderayi <steven.oderayi@modusbox.com>
|
23
|
+
|
24
|
+
--------------
|
25
|
+
******/
|
26
|
+
'use strict'
|
27
|
+
|
28
|
+
const Enum = require('@mojaloop/central-services-shared').Enum
|
29
|
+
const LibUtil = require('../../../../lib/util')
|
30
|
+
const parties = require('../../../../domain/parties')
|
31
|
+
const Metrics = require('@mojaloop/central-services-metrics')
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Operations on /parties/{Type}/{ID}/{SubId}
|
35
|
+
*/
|
36
|
+
module.exports = {
|
37
|
+
/**
|
38
|
+
* summary: PartiesSubIdByTypeAndID
|
39
|
+
* description: The HTTP request GET /parties/<Type>/<ID> (or GET /parties/<Type>/<ID>/<SubId>) is used to lookup information regarding the requested Party, defined by <Type>, <ID> and optionally <SubId> (for example, GET /parties/MSISDN/123456789, or GET /parties/BUSINESS/shoecompany/employee1).
|
40
|
+
* parameters: Accept
|
41
|
+
* produces: application/json
|
42
|
+
* responses: 202, 400, 401, 403, 404, 405, 406, 501, 503
|
43
|
+
*/
|
44
|
+
get: function (context, request, h) {
|
45
|
+
const histTimerEnd = Metrics.getHistogram(
|
46
|
+
'ing_getPartiesByTypeIDAndSubID',
|
47
|
+
'Ingress - Get party by Type, ID and SubId',
|
48
|
+
['success']
|
49
|
+
).startTimer()
|
50
|
+
const { cache, proxyCache } = request.server.app
|
51
|
+
parties.getPartiesByTypeAndID(request.headers, request.params, request.method, request.query, request.span, cache, proxyCache).catch(err => {
|
52
|
+
request.server.log(['error'], `ERROR - getPartiesByTypeAndID: ${LibUtil.getStackOrInspect(err)}`)
|
53
|
+
})
|
54
|
+
histTimerEnd({ success: true })
|
55
|
+
return h.response().code(Enum.Http.ReturnCodes.ACCEPTED.CODE)
|
56
|
+
},
|
57
|
+
/**
|
58
|
+
* summary: PartiesSubIdByTypeAndID
|
59
|
+
* description: The callback PUT /parties/<Type>/<ID> (or PUT /parties/<Type>/<ID>/<SubId>) is used to inform the client of a successful result of the Party information lookup.
|
60
|
+
* parameters: body, Content-Length
|
61
|
+
* produces: application/json
|
62
|
+
* responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
|
63
|
+
*/
|
64
|
+
put: function (context, request, h) {
|
65
|
+
const histTimerEnd = Metrics.getHistogram(
|
66
|
+
'ing_putPartiesByTypeIDAndSubID',
|
67
|
+
'Ingress - Put parties by Type, ID and SubId',
|
68
|
+
['success']
|
69
|
+
).startTimer()
|
70
|
+
const { cache, proxyCache } = request.server.app
|
71
|
+
parties.putPartiesByTypeAndID(request.headers, request.params, request.method, request.payload, request.dataUri, cache, proxyCache).catch(err => {
|
72
|
+
request.server.log(['error'], `ERROR - putPartiesByTypeAndID: ${LibUtil.getStackOrInspect(err)}`)
|
73
|
+
})
|
74
|
+
histTimerEnd({ success: true })
|
75
|
+
return h.response().code(Enum.Http.ReturnCodes.OK.CODE)
|
76
|
+
}
|
77
|
+
}
|