Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

@bbc/http-transport-rate-limiter

Package Overview
Dependencies
Maintainers
20
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbc/http-transport-rate-limiter

A global plugin for http-transport to utilise the simple-rate-limiter

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
16
-60%
Maintainers
20
Weekly downloads
 
Created
Source

NPM downloads Build Status npm license github-issues stars forks

http-transport-rate-limiter

A global plugin for http-transport to utilise the simple-rate-limiter.

Usage

Configure the plugin as shown below. You can then use it as a global plugin for http-transport.

const simpleRateLimiterPlugin = require('@bbc/http-transport-rate-limiter')(count, duration);

The plugin takes two arguments:

  • count: The amount of calls that are allowed per time window
  • duration: The length of the time window to restrict calls within. In milliseconds.

Example

'use strict';

const url = 'http://example.com/';
const simpleRateLimiterPlugin = require('@bbc/http-transport-rate-limiter');

const client = require('@bbc/http-transport').createBuilder()
  .use(simpleRateLimiterPlugin(2, 1000)
  .createClient();

const res = await client
  .get(url)
  .asResponse();
 
if (res.statusCode === 200) {
  console.log(res.body);
}

FAQs

Package last updated on 29 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts