Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

express-rate-limit

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-rate-limit - npm Package Compare versions

Comparing version 6.4.0 to 6.5.1

8

changelog.md

@@ -9,2 +9,10 @@ # Changelog

## [6.5.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.5.0)
## Changed
- The message option can now be a (sync/asynx) function that returns a value
(#311)
- Updated all dependencies
## [6.4.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.3.0)

@@ -11,0 +19,0 @@

6

dist/index.d.ts

@@ -1,2 +0,2 @@

// Generated by dts-bundle-generator v6.8.0
// Generated by dts-bundle-generator v6.12.0

@@ -155,3 +155,3 @@ import { NextFunction, Request, RequestHandler, Response } from 'express';

*/
readonly message: any;
readonly message: any | ValueDeterminingMiddleware<any>;
/**

@@ -280,3 +280,3 @@ * The HTTP status code to send back when a client is rate limited.

*/
export declare const rateLimit: (passedOptions?: Partial<Options> | undefined) => RateLimitRequestHandler;
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
/**

@@ -283,0 +283,0 @@ * A `Store` that stores the hit count for each client in memory.

{
"name": "express-rate-limit",
"version": "6.4.0",
"version": "6.5.1",
"description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",

@@ -73,21 +73,21 @@ "author": {

"devDependencies": {
"@jest/globals": "27.4.6",
"@jest/globals": "28.1.3",
"@types/express": "4.17.13",
"@types/jest": "27.4.1",
"@types/node": "16.11.27",
"@types/jest": "28.1.6",
"@types/node": "18.0.6",
"@types/supertest": "2.0.12",
"cross-env": "7.0.3",
"del-cli": "4.0.1",
"dts-bundle-generator": "6.8.0",
"esbuild": "0.14.38",
"express": "4.17.3",
"husky": "7.0.4",
"jest": "27.5.1",
"lint-staged": "12.4.0",
"dts-bundle-generator": "6.12.0",
"esbuild": "0.14.49",
"express": "4.18.1",
"husky": "8.0.1",
"jest": "28.1.3",
"lint-staged": "13.0.3",
"npm-run-all": "4.1.5",
"supertest": "6.2.2",
"ts-jest": "27.1.4",
"ts-node": "10.7.0",
"typescript": "4.6.3",
"xo": "0.48.0"
"supertest": "6.2.4",
"ts-jest": "28.0.7",
"ts-node": "10.9.1",
"typescript": "4.7.4",
"xo": "0.49.0"
},

@@ -94,0 +94,0 @@ "xo": {

@@ -242,7 +242,26 @@ # <div align="center"> Express Rate Limit </div>

May be a `string`, JSON object, or any other value that Express's
[response.send](https://expressjs.com/en/4x/api.html#response.send) method
supports.
[`response.send`](https://expressjs.com/en/4x/api.html#res.send) method
supports. It can also be a (sync/async) function that accepts the Express
request and response objects and then returns a `string`, JSON object or any
other value the Express `response.send` function accepts.
Defaults to `'Too many requests, please try again later.'`
An example of using a function:
```ts
const isPremium = async (user) => {
// ...
}
const limiter = rateLimit({
// ...
message: async (request, response) => {
if (await isPremium(request.user))
return 'You can only make 10 requests every hour.'
else return 'You can only make 5 requests every hour.'
},
})
```
### `statusCode`

@@ -352,3 +371,4 @@

By default, sends back the `statusCode` and `message` set via the options:
By default, sends back the `statusCode` and `message` set via the `options`,
similar to this:

@@ -355,0 +375,0 @@ ```ts

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc