Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settlement-v2 merge into master #259

Merged
merged 21 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
79cd24a
feature/1095 Close Settlement Window Changes (#220)
ggrg Jan 10, 2020
d2bbf6e
Added unit test for API index.js . Code coverage now 89.5 percent
Jan 13, 2020
dece580
Removed unnecessary commented lines from test
Jan 13, 2020
a6c1a6c
Added unit tests for lib/healthcheck
Jan 14, 2020
c41889c
feature/1096 Create Settlement Changes #1 (#224)
ggrg Jan 14, 2020
a1b74aa
Deleted code to fix the two plugin issues and unit test for Handler -…
Jan 14, 2020
848b85e
Merge branch 'settlement-v2' of https://github.com/mojaloop/central-s…
Jan 14, 2020
c6ac906
feature/1097 Create Settlement Changes #2 (#225)
ggrg Jan 15, 2020
f73b481
feature/1099 Update Settlement by ID Changes (#229)
ggrg Jan 20, 2020
09914d0
feature/1165 Unit tests for central-settlement part1
Jan 24, 2020
8bf57cf
Merge branch 'master' of github.com:mojaloop/central-settlement into …
ggrg Jan 24, 2020
6921056
feature/1100 Settlement By Currency Wrap Up (#231)
ggrg Jan 27, 2020
059ae47
Feature/1180 enhance get settlement windows by (#238)
Feb 10, 2020
028b9e9
feature/1211 Auto position reset (#240)
ggrg Feb 12, 2020
504edb4
Merge branch 'master' of github.com:mojaloop/central-settlement into …
ggrg Feb 20, 2020
8282497
feature/1209 Restrict Create Settlement (#249)
ggrg Feb 20, 2020
63af5e3
Feature/926 enhanced get settlement windows by params (#254)
lazolalucas Feb 26, 2020
757e649
Prepare version for PR against master
ggrg Feb 26, 2020
38d70d1
Trigger circle CI re-run
ggrg Feb 26, 2020
ad03ad2
Downgrade @mojaloop/central-services-database due to integration test…
ggrg Feb 26, 2020
9de229c
Address PR review request and update dependencies
ggrg Feb 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ncurc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@hapi/inert",
"@hapi/vision",
"@hapi/joi",
"@mojaloop/central-services-database",
"hapi-swagger"
]
}
57 changes: 57 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,55 @@
"CREATE_RETRY_INTERVAL_MILLIS": 200,
"DEBUG": false
},
"WINDOW_AGGREGATION": {
"RETRY_COUNT": 3,
"RETRY_INTERVAL": 3000
lewisdaly marked this conversation as resolved.
Show resolved Hide resolved
},
"TRANSFER_VALIDITY_SECONDS": "432000",
"HUB_PARTICIPANT": {
"ID": 1,
"NAME": "Hub"
},
"HANDLERS": {
"DISABLED": false,
"API": {
"DISABLED": false
}
},
"KAFKA": {
"TOPIC_TEMPLATES": {
"GENERAL_TOPIC_TEMPLATE": {
"TEMPLATE": "topic-{{functionality}}-{{action}}",
"REGEX": "topic-(.*)-(.*)"
}
},
"CONSUMER": {
"SETTLEMENTWINDOW": {
"CLOSE": {
"config": {
"options": {
"mode": 2,
"batchSize": 1,
"pollFrequency": 10,
"recursiveTimeout": 100,
"messageCharset": "utf8",
"messageAsJSON": true,
"sync": true,
"consumeTimeout": 1000
},
"rdkafkaConf": {
"client.id": "cs-con-setlementwindow-close",
"group.id": "cs-group-setlementwindow-close",
"metadata.broker.list": "localhost:9092",
"socket.keepalive.enable": true
},
"topicConf": {
"auto.offset.reset": "earliest"
}
}
}
}
},
"PRODUCER": {
"NOTIFICATION": {
"EVENT": {
Expand All @@ -56,6 +93,26 @@
}
}
}
},
"SETTLEMENTWINDOW": {
"CLOSE": {
"config": {
"options": {
"messageCharset": "utf8"
},
"rdkafkaConf": {
"metadata.broker.list": "localhost:9092",
"client.id": "cs-prod-setlementwindow-close",
"event_cb": true,
"dr_cb": true,
"socket.keepalive.enable": true,
"queue.buffering.max.messages": 10000000
},
"topicConf": {
"request.required.acks": "all"
}
}
}
}
}
}
Expand Down
3,472 changes: 1,377 additions & 2,095 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "central-settlement",
"description": "Central settlements hosted by a scheme to record and make settlements",
"version": "9.2.1",
"version": "9.2.2",
"license": "Apache-2.0",
"private": false,
"author": "ModusBox",
Expand Down Expand Up @@ -33,10 +33,12 @@
"@mojaloop/central-services-error-handling": "9.1.0",
"@mojaloop/central-services-health": "9.2.0",
"@mojaloop/central-services-logger": "9.1.0",
"@mojaloop/central-services-shared": "9.1.4",
"@mojaloop/central-services-stream": "9.1.0",
"@mojaloop/central-services-shared": "9.2.0",
"@mojaloop/central-services-stream": "9.2.0",
"@mojaloop/ml-number": "8.2.0",
"@now-ims/hapi-now-auth": "2.0.1",
"async": "3.2.0",
"async-retry": "1.3.1",
"blipp": "4.0.1",
"hapi-auth-bearer-token": "6.2.1",
"hapi-openapi": "1.2.6",
Expand All @@ -51,6 +53,7 @@
"bluebird": "3.7.2",
"eslint": "6.8.0",
"faucet": "0.0.1",
"get-port": "5.1.1",
ggrg marked this conversation as resolved.
Show resolved Hide resolved
"node-fetch": "2.6.0",
"nodemon": "2.0.2",
"npm-audit-resolver": "2.2.0",
Expand All @@ -72,18 +75,20 @@
"test"
],
"scripts": {
"start": "node src/server.js",
"dev": "nodemon src/server.js",
"start": "run-p start:api",
"start:api": "node src/api/index.js",
"watch:api": "nodemon src/api/index.js",
"regenerate": "yo swaggerize:test --framework hapi --apiPath './src/interface/swagger.yaml'",
"standard": "standard",
"lint": "eslint .",
"test": "npm run test:unit | faucet",
"test:all": "run-s test",
"test:unit": "tape 'test/unit/**/*.js'",
"test:xunit": "tape 'test/unit/**/*.js' | tap-xunit",
"lint": "eslint .",
"test:coverage-check": "npm run test:coverage && nyc check-coverage",
"test:coverage": "nyc --reporter=lcov --reporter=text-summary tapes -- 'test/unit/**/**.test.js'",
"test:coverage-check": "npm run test:coverage && nyc check-coverage",
"test:int": "tape 'test/integration/**/*.test.js'",
"test:integration": "sh ./test/integration-runner.sh ./test/integration-runner.env",
"regenerate": "yo swaggerize:test --framework hapi --apiPath './src/interface/swagger.json'",
"audit:resolve": "SHELL=sh resolve-audit",
"audit:check": "SHELL=sh check-audit",
"dep:check": "npx ncu -e 2",
Expand Down
19 changes: 10 additions & 9 deletions src/handlers/health.js → src/api/handlers/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>

* ModusBox
- Georgi Georgiev <georgi.georgiev@modusbox.com>

* VesselsTech
- Lewis Daly <lewis@vesselstech.com>

--------------
******/

'use strict'

const Logger = require('@mojaloop/central-services-logger')
const HealthCheck = require('@mojaloop/central-services-shared').HealthCheck.HealthCheck
const { defaultHealthHandler } = require('@mojaloop/central-services-health')
const Path = require('path')

const packageJson = require('../../package.json')
const { getSubServiceHealthDatastore } = require('./lib/healthCheck/subServiceHealth')

Logger.info('path ', Path.basename(__filename))
const packageJson = require('../../../package.json')
const {
getSubServiceHealthDatastore,
getSubServiceHealthBroker
} = require('../../lib/healthCheck/subServiceHealth')

const healthCheck = new HealthCheck(packageJson, [
getSubServiceHealthDatastore
getSubServiceHealthDatastore,
getSubServiceHealthBroker
])

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>

* Valentin Genev <valentin.genev@modusbox.com>
* Deon Botha <deon.botha@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>
* ModusBox
- Deon Botha <deon.botha@modusbox.com>
- Georgi Georgiev <georgi.georgiev@modusbox.com>
- Miguel de Barros <miguel.debarros@modusbox.com>
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
- Valentin Genev <valentin.genev@modusbox.com>
--------------
******/

'use strict'

const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Logger = require('@mojaloop/central-services-logger')
const Path = require('path')
const settlementWindows = require('./../domain/settlementWindow')
Logger.info('path ', Path.basename(__filename))
const settlementWindows = require('../../domain/settlementWindow/index')

/**
* Operations on /settlementWindows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>

* Valentin Genev <valentin.genev@modusbox.com>
* Deon Botha <deon.botha@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>

* ModusBox
- Deon Botha <deon.botha@modusbox.com>
- Miguel de Barros <miguel.debarros@modusbox.com>
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
- Valentin Genev <valentin.genev@modusbox.com>
--------------
******/

'use strict'

const settlementWindow = require('../../domain/settlementWindow/index')
const settlementWindow = require('../../../domain/settlementWindow/index')
const ErrorHandler = require('@mojaloop/central-services-error-handling')

/**
Expand Down Expand Up @@ -65,11 +64,11 @@ module.exports = {
* responses: 200, 400, 401, 404, 415, default
*/
post: async function closeSettlementWindow (request) {
const { state, reason } = request.payload
const { reason } = request.payload
const settlementWindowId = request.params.id
try {
const Enums = await request.server.methods.enums('settlementWindowStates')
return await settlementWindow.close({ settlementWindowId, state, reason }, Enums)
return await settlementWindow.process({ settlementWindowId, reason }, Enums)
} catch (err) {
request.server.log('error', err)
return ErrorHandler.Factory.reformatFSPIOPError(err)
Expand Down
26 changes: 12 additions & 14 deletions src/handlers/settlements.js → src/api/handlers/settlements.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,18 @@
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>

* Georgi Georgiev <georgi.georgiev@modusbox.com>
* Valentin Genev <valentin.genev@modusbox.com>
* Deon Botha <deon.botha@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>

* ModusBox
- Deon Botha <deon.botha@modusbox.com>
- Georgi Georgiev <georgi.georgiev@modusbox.com>
- Miguel de Barros <miguel.debarros@modusbox.com>
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
- Valentin Genev <valentin.genev@modusbox.com>
--------------
******/

'use strict'

const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Logger = require('@mojaloop/central-services-logger')
const Path = require('path')
const Settlements = require('./../domain/settlement')

Logger.info('path ', Path.basename(__filename))
const Settlements = require('../../domain/settlement/index')

/**
* Operations on /settlements
Expand Down Expand Up @@ -71,11 +66,14 @@ module.exports = {
post: async function createSettlementEvent (request, h) {
try {
const Enums = {
ledgerEntryTypes: await request.server.methods.enums('ledgerEntryTypes'),
settlementDelay: await request.server.methods.enums('settlementDelay'),
settlementGranularity: await request.server.methods.enums('settlementGranularity'),
settlementInterchange: await request.server.methods.enums('settlementInterchange'),
settlementStates: await request.server.methods.enums('settlementStates'),
settlementWindowStates: await request.server.methods.enums('settlementWindowStates'),
transferStates: await request.server.methods.enums('transferStates'),
transferParticipantRoleTypes: await request.server.methods.enums('transferParticipantRoleTypes'),
ledgerEntryTypes: await request.server.methods.enums('ledgerEntryTypes')
transferStates: await request.server.methods.enums('transferStates')
}
const settlementResult = await Settlements.settlementEventTrigger(request.payload, Enums)
return h.response(settlementResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,18 @@
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>

* Georgi Georgiev <georgi.georgiev@modusbox.com>
* Valentin Genev <valentin.genev@modusbox.com>
* Deon Botha <deon.botha@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>

* ModusBox
- Deon Botha <deon.botha@modusbox.com>
- Georgi Georgiev <georgi.georgiev@modusbox.com>
- Miguel de Barros <miguel.debarros@modusbox.com>
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
- Valentin Genev <valentin.genev@modusbox.com>
--------------
******/

'use strict'

const ErrorHandler = require('@mojaloop/central-services-error-handling')

const Settlements = require('../../domain/settlement')
const Logger = require('@mojaloop/central-services-logger')
const Path = require('path')

Logger.info('path ', Path.basename(__filename))
const Settlements = require('../../../domain/settlement/index')

/**
* Operations on /settlements/{id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,18 @@
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>

* Georgi Georgiev <georgi.georgiev@modusbox.com>
* Valentin Genev <valentin.genev@modusbox.com>
* Deon Botha <deon.botha@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>

* ModusBox
- Deon Botha <deon.botha@modusbox.com>
- Georgi Georgiev <georgi.georgiev@modusbox.com>
- Miguel de Barros <miguel.debarros@modusbox.com>
- Rajiv Mothilal <rajiv.mothilal@modusbox.com>
- Valentin Genev <valentin.genev@modusbox.com>
--------------
******/

'use strict'

const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Path = require('path')
const Logger = require('@mojaloop/central-services-logger')
const Settlements = require('../../../../domain/settlement')

Logger.info('path ', Path.basename(__filename))
const Settlements = require('../../../../../domain/settlement/index')

/**
* Operations on /settlements/{settlementId}/participants/{participantId}
Expand All @@ -58,7 +53,8 @@ module.exports = {
settlementWindowStates: await request.server.methods.enums('settlementWindowStates'),
ledgerAccountTypes: await request.server.methods.enums('ledgerAccountTypes')
}
const { settlementId, participantId } = request.params
const settlementId = request.params.sid
const participantId = request.params.pid
const result = await Settlements.getByIdParticipantAccount({ settlementId, participantId }, Enums)
return h.response(result)
} catch (err) {
Expand All @@ -75,8 +71,8 @@ module.exports = {
* responses: 200, 400, 401, 404, 415, default
*/
put: async function updateSettlementById (request) {
const settlementId = request.params.settlementId
const participantId = request.params.participantId
const settlementId = request.params.sid
const participantId = request.params.pid
try {
const p = request.payload
const universalPayload = {
Expand Down
Loading