Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onfleet/node-onfleet

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onfleet/node-onfleet - npm Package Compare versions

Comparing version 1.0.5 to 1.0.7

lib/constants.js

25

lib/Methods.js

@@ -0,2 +1,4 @@

const Bottleneck = require('bottleneck');
const fetch = require('node-fetch');
const constants = require('./constants');
const util = require('./util');

@@ -10,2 +12,17 @@ const {

// Create new rate limiter using defined constants
const limiter = new Bottleneck({
reservoirRefreshInterval: constants.LIMITER_REFRESH_INTERVAL,
maxConcurrent: constants.LIMITER_MAX_CONCURRENT,
minTime: constants.LIMITER_MIN_TIME,
});
// Rate reservoir refresh on every response
// New rate is determined by x-ratelimit-remaining in headers
const reassignRate = (newRate) => {
limiter.updateSettings({
reservoirRefreshAmount: newRate,
});
};
/**

@@ -78,4 +95,4 @@ * The Method Factory

// Send the HTTP request
return fetch(url, {
// Send the HTTP request through the rate limiter
return limiter.schedule(() => fetch(url, {
method: operations,

@@ -87,2 +104,4 @@ headers: api.api.headers,

if (res.ok) {
// On response, update the rate
reassignRate(res.headers.get('x-ratelimit-remaining'));
// Return status code for deletion as the API does, else, return the body of the response

@@ -112,5 +131,5 @@ return operations === 'DELETE' ? res.status : res.json();

throw (error);
});
}));
};
module.exports = Methods;

6

package.json
{
"name": "@onfleet/node-onfleet",
"version": "1.0.5",
"version": "1.0.7",
"description": "Official client library for accessing the Onfleet API",

@@ -23,3 +23,4 @@ "main": "index.js",

"dependencies": {
"node-fetch": "^2.3.0"
"bottleneck": "^2.19.5",
"node-fetch": "^2.6.0"
},

@@ -32,2 +33,3 @@ "devDependencies": {

"eslint-plugin-import": "^2.16.0",
"minimist": "^0.2.1",
"mocha": "^6.1.4",

@@ -34,0 +36,0 @@ "nock": "^10.0.6"

@@ -77,3 +77,3 @@ # Onfleet Node.js Wrapper

### étranglement
La limitation de débit est appliquée par l'API avec un seuil de 20 demandes par seconde pour toutes les clés d'API de votre organisation. Pour en savoir plus, [cliquez ici](https://docs.onfleet.com/reference#throttling).
La limitation de débit est appliquée par l'API avec un seuil de 20 demandes par seconde pour toutes les clés d'API de votre organisation. Pour en savoir plus, [cliquez ici](https://docs.onfleet.com/reference#throttling). Nous avons mis en place un limiteur sur le wrapper lui-même pour vous éviter de dépasser involontairement vos limitations de taux et éventuellement être banni.

@@ -80,0 +80,0 @@ ### Réponses

@@ -76,3 +76,3 @@ # Onfleet Node.js Wrapper

### Throttling
Rate limiting is enforced by the API with a threshold of 20 requests per second across all your organization's API keys, learn more about it [here](https://docs.onfleet.com/reference#throttling).
Rate limiting is enforced by the API with a threshold of 20 requests per second across all your organization's API keys, learn more about it [here](https://docs.onfleet.com/reference#throttling). We have implemented a limiter on the wrapper itself to avoid you from unintentionally exceeding your rate limitations and eventually be banned for.

@@ -79,0 +79,0 @@ ### Responses

@@ -79,3 +79,3 @@ # Onfleet Node.js Wrapper

### API速限
原則上API的速限為每秒鐘20次請求,詳情請參考[官方文件](https://docs.onfleet.com/reference#throttling)
原則上API的速限為每秒鐘20次請求,詳情請參考[官方文件](https://docs.onfleet.com/reference#throttling)。在此模組內我們也提供了限速,以避免您無意間超過了API請求的速限而導致帳號被禁的狀況。

@@ -82,0 +82,0 @@ ### 請求回應

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc