@onfleet/node-onfleet
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -9,5 +9,9 @@ # Changelog | ||
## [1.2.8] - 2021-10-11 | ||
### Changed | ||
- Relocate `depleted` event handler | ||
## [1.2.7] - 2021-08-23 | ||
### Added | ||
- Enable passing a baseURL param to `Onfleet`'s constructor | ||
- Enable passing `baseURL` as param to `Onfleet`'s constructor | ||
- README in ES | ||
@@ -95,4 +99,5 @@ - CHANGELOG | ||
[Unreleased]: https://github.com/onfleet/node-onfleet/compare/v1.2.7...HEAD | ||
[1.2.6]: https://github.com/onfleet/node-onfleet/compare/v1.2.6...v1.2.7 | ||
[Unreleased]: https://github.com/onfleet/node-onfleet/compare/v1.2.8...HEAD | ||
[1.2.8]: https://github.com/onfleet/node-onfleet/compare/v1.2.7...v1.2.8 | ||
[1.2.7]: https://github.com/onfleet/node-onfleet/compare/v1.2.6...v1.2.7 | ||
[1.2.6]: https://github.com/onfleet/node-onfleet/compare/v1.2.5...v1.2.6 | ||
@@ -99,0 +104,0 @@ [1.2.5]: https://github.com/onfleet/node-onfleet/compare/v1.2.4...v1.2.5 |
@@ -38,2 +38,11 @@ /* eslint-disable no-console */ | ||
// On reservoir depletion, we wait 10000ms and reset the rate again (20 req/second limitation) | ||
limiter.on('depleted', (empty) => { | ||
if (!empty) { | ||
wait(constants.LIMITER_WAIT_UPON_DEPLETION).then(() => { | ||
reassignRate(constants.LIMITER_RESERVOIR); | ||
}); | ||
} | ||
}); | ||
/** | ||
@@ -112,11 +121,5 @@ * The Method Factory | ||
body: hasBody ? JSON.stringify(body) : undefined, | ||
}).then((res) => { | ||
// On reservoir depletion, we wait 10000ms and reset the rate again (20 req/second limitation) | ||
limiter.on('depleted', (empty) => { | ||
if (!empty) { | ||
wait(constants.LIMITER_WAIT_UPON_DEPLETION).then(() => { | ||
reassignRate(constants.LIMITER_RESERVOIR); | ||
}); | ||
} | ||
}); | ||
})) | ||
.then((res) => { | ||
// For every request, we compare the reservoir with the remainding rate limit in the header | ||
@@ -134,2 +137,3 @@ limiter.currentReservoir() | ||
} | ||
return res.json().then((error) => { | ||
@@ -156,7 +160,9 @@ // Throws custom error according to errorCode | ||
}); | ||
}).catch((error) => { | ||
}) | ||
.catch((error) => { | ||
throw (error); | ||
})); | ||
}); | ||
}; | ||
module.exports = Methods; |
{ | ||
"name": "@onfleet/node-onfleet", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "Onfleet's Node.js API Wrapper Package", | ||
@@ -17,2 +17,5 @@ "main": "index.js", | ||
"author": "James Li", | ||
"contributors": [ | ||
"Julián Pérez" | ||
], | ||
"license": "MIT", | ||
@@ -19,0 +22,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90254
1088