diff --git a/gentong.js b/gentong.js index 2dfb22d..6454a32 100644 --- a/gentong.js +++ b/gentong.js @@ -41,6 +41,8 @@ function generateTimestamp(request_id) { } function topupRequest(task) { + aaa.insertTaskToMongoDb(task); + var ts = strftime('%F %T', new Date()); ts = generateTimestamp(task['requestId']); @@ -354,15 +356,28 @@ function responseCodeFromMessage(message) { return; } -function start(_config, _callbackReport, options) { - config = _config; - callbackReport = _callbackReport +function start(options) { + if (!options) { + console.log('Undefined options, terminating....'); + process.exit(1); + } + + if (options.config) { + config = options.config; + } else { + console.log('Undefined options.config, terminating....') + process.exit(1); + } - if (options && options.aaa) { - aaa = options.aaa; + if (options.aaa) { + aaa = options.aaa; + callbackReport = options.aaa.callbackReportWithPushToMongoDb; + } else { + console.log('Undefined options.aaa, terminating....') + process.exit(1); } - if (options && options.logger) { + if (options.logger) { logger = options.logger; } else { logger = new winston.Logger({ diff --git a/index.js b/index.js index 0c718b9..d76afd5 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,6 @@ var options = { var httpServer = HttpServer.start(config, options); //HttpServer.setAaa(aaa); -partner.start(config, aaa.callbackReport, options); +partner.start(options); aaa.start(config, partner, options); expresso.start(options);