nfriedly / rate-limit-memcached

A rate limiting store for express-rate-limit with Memcached

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rate Limit Memcached

Memcached client for the express-rate-limit middleware.

Installation

$ npm install --save rate-limit-memcached

Usage

Node.js

var RateLimit = require('express-rate-limit');
var Memcached = require('memcached');
var MemcachedStore = require('rate-limit-memcached');

var client = new Memcached(['memcached.example.com:11211']);
var expiration = 20 * 60;
var limiter = new RateLimit({
  store: new MemcachedStore({ expiration: expiration, client: client, prefix: 'remoteip:' }),
  windowMs: expiration * 1000,
  max: 500,
  delayMs: 0
});

app.use(limiter);

TypeScript

import * as RateLimit from 'express-rate-limit'
import * as Memcached from 'memcached'
import MemcachedStore from 'rate-limit-memcached'

const client = new Memcached(['memcached.example.com:11211'])
const expiration = 20 * 60
const limiter = new RateLimit({
  store: new MemcachedStore({ expiration, client, prefix: 'remoteip:' }),
  windowMs: expiration * 1000,
  max: 500,
  delayMs: 0
})

app.use(limiter)

Contribution

  1. Fork (https://github.com/linyows/rate-limit-memcached/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the npm ci command and confirm that it passes
  6. Create a new Pull Request

Author

linyows

About

A rate limiting store for express-rate-limit with Memcached

License:MIT License


Languages

Language:TypeScript 94.5%Language:JavaScript 5.5%