构build自定义API连接器的常用方法是什么?

我大多具有编程经验作为Web开发人员,现在我的任务是build立两个rest服务之间的整合。 应用程序假设每5分钟从一个REST服务读取一次,并将数据发送到另一个服务。 我需要存储一个checkSUM值,以便在下次调用时使用。

目前我正考虑在Node和Express中构build它,并使用“定制时钟进程”在heroku上进行托pipe。 但是我不确定构build这样的应用程序的最佳方式是什么。 在没有看法的情况下开发应用程序对我来说是相当陌生的。 MVC甚至在这样的应用程序有意义吗?

任何人都可以指向资源解释一个好方法来处理这样的应用程序?

即使没有视图层,expression是否有意义?

什么是一个很好的方法来存储一个单一的值,如checkSUM或SyncKey? 是一个数据库矫枉过正?

这样的应用程序的文件夹结构是什么样的。

我知道这是一个相当广泛的问题。 我主要是在寻找build议和资源,以及其他人如何解决这个问题。 你会用什么技术?

您可以使用请求包向您的服务发送请求。 和cron包安排你的任务,每5分钟。

这里是这个场景的简单代码

var request = require('request'); var CronJob = require('cron').CronJob; var SOURCE_SERVICE_URL = "http://your.source.service/endpoint"; var DESTINATION_SERVICE_URL = "http://your.destination.service/endpoint"; //initialize this value when you get checkSUM from request and use to compare next checkSUM var lastCheckSUM = ""; var everyMinuteJob = new CronJob({ cronTime: '*/5 * * * *', onTick: function () { console.log("Task started"); task_1(); //you can create and add tasks for other endpoints }, start: true }); var task_1 = function () { request(SOURCE_SERVICE_URL, function (error, response, body) { if (error) { console.log("Can not read data from source service.") return console.log(error); } console.log("Data read : " + body); //TODO - check the checkSUM value of response. Then set it to lastCheckSUM request .post(DESTINATION_SERVICE_URL, body, function (error, response, body) { if (error) { console.log("Can not send data to destination service.") return console.log(error); } }) }); }