JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11861
  • Score
    100M100P100Q144732F
  • License MIT

Provides a Mongo store for the express-rate-limit middleware.

Package Exports

  • rate-limit-mongo

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rate-limit-mongo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Rate Limit Mongo

Mongo client for the express-rate-limit middleware.

Npm version Build Status

Install

$ npm install --save rate-limit-mongo

Usage

var RateLimit = require('express-rate-limit');
var MongoStore = require('rate-limit-mongo');

var limiter = new RateLimit({
  store: new MongoStore({
    // see Configuration
  }),
  max: 100,
  windowMs: 15 * 60 * 1000
});

//  apply to all requests
app.use(limiter);

Configuration

  • uri: string -- uri for connecting to mongodb, mongodb://127.0.0.1:27017/test_db for example. Required if collection hasn't been set.

  • collectionName: string -- name of collection for storing records. Defaults to expressRateRecords

  • user: string -- username for authentication in mongodb

  • password: string -- password for authentication in mongodb

  • authSource: string -- db name against which authenticate use. If not set db name from uri will be taken.

  • collection: object -- mongodb collection instance. Required if uri hasn't been set.

  • expireTimeMs: integer -- time period, in milliseconds, after which record will be reseted (deleted). Defaults to 60 * 1000.

  • resetExpireDateOnChange: boolean -- indicates whether expireDate should be reseted when changed or not. Defaults to false.

  • errorHandler: function -- function that will be called if error happened during incr, decrement or resetKey methods. Defaults to _.noop