tommyfok / rate-limiter

rate-limiter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rate-limiter

A node rate limiter with cluster support

install

tnpm i -S @tencent/rate-limiter

use

const limitKey = 'testkey'
const RL = require('@tencent/rate-limiter')
const rl = new RL({
    time: 100, // ms
    limit: 200,
    key: limitKey
})

rl.check().then(pass => {
    if (pass === true) {
        console.log('"${limitKey}" is not limited')
    } else {
        console.log('"${limitKey}" is limited')
    }
}).catch(e => console.log)

About

rate-limiter


Languages

Language:JavaScript 100.0%