diff --git a/api/controller.js b/api/controller.js index 2505cd2..e170f84 100644 --- a/api/controller.js +++ b/api/controller.js @@ -33,6 +33,15 @@ var controllers = { res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': dist.result,'total_record': dist.total_record }) }); }, + eventSendMoney: function(req, res) { + ebroker.eventSendMoney(req, res, function(err, dist) { + if (err) { + res.send(err); + } + // res.json(dist); + res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': dist.result,'total_record': dist.total_record }) + }); + }, getUsersKidsWallets: function(req, res) { wallets.getuserkidswallet(req, res, function(err, dist) { if (err) { diff --git a/api/routes.js b/api/routes.js index f99dc56..b668fcb 100644 --- a/api/routes.js +++ b/api/routes.js @@ -18,4 +18,7 @@ module.exports = function(app) { app.route('/flutterOkHook') .post(controller.flutterOkHook); + app.route('/eventSendMoney') + .post(controller.eventSendMoney); + }; \ No newline at end of file diff --git a/service/ebroker.js b/service/ebroker.js index 4de4e7f..2c137f7 100644 --- a/service/ebroker.js +++ b/service/ebroker.js @@ -32,7 +32,31 @@ var ebroker = { } next(null, resultItem ); // pass control to the next handler }, + eventSendMoney: function (req, res, next) { + try { + const { message } = req.body; + console.log('THIS-> req.body -> ', req.body); + const kafkaConfig = new KafkaConfig(); + const messages = [{ key: "send", value: JSON.stringify(message) }]; + kafkaConfig.produce("SENDMONEY_RECEIVED", messages).then(r =>{ + console.log('THIS->RET-> ',r); + } ); + + res.status(200).json({ + status: "Ok!", + message: "Message successfully send!", + }); + } catch (error) { + console.log(error); + } + + let resultItem ={ + "result": [], + "total_record": 0 + } + next(null, resultItem ); // pass control to the next handler + }, eventConsumer: function (req, res, next) { //console.log("REQ---->",req.body.uid);