diff --git a/.travis.yml b/.travis.yml index d1d0222..8798947 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,9 @@ language: node_js node_js: - '4.2.2' +before_script: + - npm install + script: "npm test" -after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" \ No newline at end of file + +after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" diff --git a/lib/config.js b/lib/config.js index da08560..b02a803 100644 --- a/lib/config.js +++ b/lib/config.js @@ -22,6 +22,7 @@ var config = { httpProtocol: httpProtocol, appHost: appHost, apiHost: apiHost, - requestLimit: 40 + requestLimit: 40, + requestTimeout: 510 }; module.exports = config; diff --git a/lib/request.js b/lib/request.js index fcedebd..4060b5f 100644 --- a/lib/request.js +++ b/lib/request.js @@ -7,7 +7,7 @@ var querystring = require('querystring'), var request = function(options, params, callback) { if (requestCount == config.requestLimit) { - setTimeout(request, 500, options, params, callback); + setTimeout(request, config.requestTimeout, options, params, callback); return; } requestCount++; @@ -20,7 +20,7 @@ var request = function(options, params, callback) { } catch (err) { callback(err); } finally { - setTimeout(fnReduceRequestCount, config.requestLimit * 500 * eval(res.headers['x-yhsd-shop-api-call-limit'])); + setTimeout(fnReduceRequestCount, config.requestLimit * config.requestTimeout * eval(res.headers['x-yhsd-shop-api-call-limit'])); } callback(null, data); }); diff --git a/package.json b/package.json index 64fb636..8efd434 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yhsd-api", - "version": "1.0.4", + "version": "1.0.5", "description": "Youhaosuda API SDK for node.", "main": "index.js", "repository": {