Skip to content
Distributed rate limiting on Node.js
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
jest.config.json
package.json
tsconfig.build.json
tsconfig.json
tslint.json

README.md

js-counter

Build Status Coverage Status

Distributed rate limiting with pluggable storage for storing counters state.

Basic usage

// Create new Counter
const counter = new Counter({ limit: 1, ttl: 100 })
try {
  // Increment counter and get remainder
  const remainder = await counter.count('key')
  // Counter value equals 1
  // Remainder value equals 0
  // Next counter.count('key') call will return TTLError
} catch (err) {
  if (err instanceof TTLError) {
    // Use err.TTL() if need
  } else {
    // Handle err
  }
}

Example usage

You can’t perform that action at this time.