Skip to content

Commit

Permalink
Feature/Bulk Transfers POC - Bulk prepare (mojaloop#116)
Browse files Browse the repository at this point in the history
* package-lock.json
* Fix issues with object store usage
* Additional changes to Object Store and Kafka config
* Add MONGODB.URI config
* Updated package.json
* Add license info
* Updated integration tests run config
* Init BulkProcessingHandler
* WIP #1
* message.id=uuid() during Transfer Prepare
* Removed kafkaConf.key
Switched to message.id=UUID for fulfil and get
28 unit tests fail
* Fixed unit tests
* Unifying mongo schema definitions
* Finilize ml-api-adapter, but unit tests hang
* Fix mongoose unique index issue
* Fixed integration tests: uriParams added
* Changes as per PR review comments
* Putting central-object-store library - wip
* Re-factored objStore lib to be re-usable between both ml-api and central-ledger
* Fixing issue with unit tests
* Fix standard issues
* Add mdebarros as contributor and remove unused code
* Removing local objectStoreLib
* updated objectstore connection server setup to handle bad connection
  • Loading branch information
ggrg authored Jun 20, 2019
1 parent 1519114 commit efcf7c4
Show file tree
Hide file tree
Showing 21 changed files with 378 additions and 335 deletions.
6 changes: 3 additions & 3 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"generateTimeout": 30000
},
"MONGODB": {
"URI": "mongodb://localhost:27017/bulk_transfers"
"URI": "mongodb://localhost:27017/mlos"
},
"ENDPOINT_SECURITY":{
"TLS": {
Expand Down Expand Up @@ -87,7 +87,7 @@
}
},
"PRODUCER": {
"BULK-TRANSFER": {
"BULK": {
"PREPARE": {
"config": {
"options": {
Expand All @@ -101,7 +101,7 @@
"socket.keepalive.enable": true,
"queue.buffering.max.messages": 10000000
},
"topicConf": {
"topicConf": {
"request.required.acks": "all"
}
}
Expand Down
75 changes: 75 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@
"generate-docs": "node_modules/.bin/jsdoc -c jsdoc.json"
},
"dependencies": {
"bulk-api": "file:src/bulkApi",
"@hapi/basic": "5.1.0",
"@hapi/boom": "7.4.2",
"@hapi/good": "8.2.0",
"@hapi/hapi": "18.3.1",
"@hapi/inert": "5.2.0",
"@hapi/joi": "15.0.3",
"@hapi/joi-date": "1.3.0",
"@hapi/vision": "5.5.2",
"@mojaloop/central-object-store": "6.4.0-snapshot",
"@mojaloop/central-services-auth": "5.2.1",
"@mojaloop/central-services-database": "5.2.1",
"@mojaloop/central-services-error-handling": "5.2.0",
Expand All @@ -70,23 +78,17 @@
"@now-ims/hapi-now-auth": "1.3.1",
"blipp": "3.1.2",
"bluebird": "3.5.3",
"@hapi/boom": "7.4.2",
"bulk-api": "file:src/bulkApi",
"catbox": "10.0.6",
"catbox-memory": "4.0.1",
"commander": "2.19.0",
"docdash": "1.0.3",
"flat": "4.1.0",
"glob": "7.1.3",
"@hapi/good": "8.2.0",
"@hapi/hapi": "18.3.1",
"@hapi/basic": "5.1.0",
"hapi-auth-bearer-token": "6.1.1",
"hapi-swagger": "9.4.2",
"immutable": "3.8.2",
"@hapi/inert": "5.2.0",
"@hapi/joi": "15.0.3",
"joi-currency-code": "2.0.2",
"@hapi/joi-date": "1.3.0",
"jsdoc": "3.6.2",
"knex": "0.16.3",
"lodash": "4.17.11",
Expand All @@ -95,8 +97,7 @@
"rc": "1.2.8",
"request": "2.88.0",
"urlsafe-base64": "1.0.0",
"uuid4": "1.1.4",
"@hapi/vision": "5.5.2"
"uuid4": "1.1.4"
},
"devDependencies": {
"async-request": "1.2.0",
Expand Down
16 changes: 10 additions & 6 deletions src/bulkApi/handlers/bulkTransfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Name Surname <[email protected]>
* Georgi Georgiev <[email protected]>
* Miguel de Barros <[email protected]>
* Valentin Genev <[email protected]>
--------------
******/
Expand All @@ -31,8 +32,9 @@
const TransferService = require('../../domain/transfer')
const Logger = require('@mojaloop/central-services-shared').Logger
const Boom = require('boom')
const { BulkTransferModel } = require('../models/bulkTransfers/bulkModels')
const BulkTransferModels = require('@mojaloop/central-object-store').Models.BulkTransfer
const Util = require('../../lib/util')
const Uuid = require('uuid4')

/**
* Operations on /bulkTransfers
Expand All @@ -48,12 +50,14 @@ module.exports = {
post: async function postBulkTransfers (request, h) {
try {
Logger.debug('create::payload(%s)', JSON.stringify(request.payload))
let { bulkTransferId, bulkQuoteId, payerFsp, payeeFsp, expiration, extensionList } = request.payload
let hash = Util.createHash(JSON.stringify(request.payload))
let newBulk = new BulkTransferModel(Object.assign({}, { headers: request.headers }, request.payload))
const { bulkTransferId, bulkQuoteId, payerFsp, payeeFsp, expiration, extensionList } = request.payload
const hash = Util.createHash(JSON.stringify(request.payload))
const messageId = Uuid()
let BulkTransferModel = BulkTransferModels.getBulkTransferModel()
const newBulk = new BulkTransferModel(Object.assign({}, { messageId, headers: request.headers }, request.payload))
await newBulk.save()
let message = { bulkTransferId, bulkQuoteId, payerFsp, payeeFsp, expiration, extensionList, hash }
await TransferService.bulkPrepare(request.headers, message)
const message = { bulkTransferId, bulkQuoteId, payerFsp, payeeFsp, expiration, extensionList, hash }
await TransferService.bulkPrepare(messageId, request.headers, message)
return h.response().code(202)
} catch (err) {
Logger.error(err)
Expand Down
6 changes: 4 additions & 2 deletions src/bulkApi/handlers/bulkTransfers/{id}.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
* Gates Foundation
- Name Surname <[email protected]>
* Georgi Georgiev <[email protected]>
* Valentin Genev <[email protected]>
--------------
******/
'use strict'

const Boom = require('boom')
const { IndividualTransferModel } = require('../../models/bulkTransfers/bulkModels')
const BulkTransferModels = require('@mojaloop/central-object-store').Models.BulkTransfer

/**
* Operations on /bulkTransfers/{id}
Expand All @@ -43,10 +44,11 @@ module.exports = {
*/
get: async function getBulkTransfersId (request, h) {
let { id } = request.params
let IndividualTransferModel = BulkTransferModels.getIndividualTransferModel()
try {
let indvidualTransfers = await IndividualTransferModel
.find({ bulkTransferId: id }, '-dataUri -_id')
.populate('bulkDocument', 'headers -_id') // TODO in bulk-handler first get only headers, then compose each individual transfer without population
.populate('_id_bulkTransfers', 'headers -_id') // TODO in bulk-handler first get only headers, then compose each individual transfer without population
return h.response(indvidualTransfers)
} catch (e) {
throw e
Expand Down
43 changes: 0 additions & 43 deletions src/bulkApi/lib/mongodb/db.js

This file was deleted.

Loading

0 comments on commit efcf7c4

Please sign in to comment.