1.1.1 • Published 1 year ago

@twentyfourg-express-sdk/rate-limit v1.1.1

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
1 year ago

@twentyfourg-express-sdk/rate-limit

Version Installs

Rate limiting middleware.

router.post(
  '/auth',
  rateLimit({ max: 10, minutes: 1, keys: ['ip', 'body.email'] }),
  validator.auth,
  userController.auth
);
OptionsDescriptionDefault
minutesTime frame in minutes for which requests are checked/remembered.1
maxThe maximum number of connections to allow during the window before rate limiting the client.15
standardHeadersWhether to enable support for headers conforming to the ratelimit standardization draft.true
messageThe response body to send back when a client is rate limited.{ error: 'too many requests, please try again later' }
keysWhich properties from the Express Request object to use in the rate limit composite key['ip', 'headers["user-agent"]']
whiteListList of IP addresses to whitelistSDK_EXPRESS_WHITE_LIST environment variable

Environment Variables

VariableDescriptionDefault
SDK_EXPRESS_WHITE_LISTString of IP addresses separated by commas to whitelist[]
EXPRESS_SDK_RATE_LIMIT_DISABLEDWhether to disable rate limiting all together. Helpful for testing/dev environments.false