express-rate-limit 6.0.3 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +8 -0
- package/package.json +7 -7
- package/readme.md +49 -4
package/changelog.md
CHANGED
|
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [6.0.3](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.3)
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Bumped minimum Node version from 12.9 to 14.5 because the transpiled output
|
|
14
|
+
uses the nullish coalescing operator (`??`), which
|
|
15
|
+
[isn't supported in node.js prior to 14.x](https://node.green/#ES2020-features--nullish-coalescing-operator-----).
|
|
16
|
+
|
|
9
17
|
## [6.0.2](https://github.com/nfriedly/express-rate-limit/releases/v6.0.2)
|
|
10
18
|
|
|
11
19
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nathan Friedly",
|
|
@@ -28,13 +28,15 @@
|
|
|
28
28
|
"attack"
|
|
29
29
|
],
|
|
30
30
|
"type": "module",
|
|
31
|
-
"types": "./dist/index.d.ts",
|
|
32
31
|
"exports": {
|
|
33
32
|
".": {
|
|
34
33
|
"import": "./dist/index.mjs",
|
|
35
34
|
"require": "./dist/index.cjs"
|
|
36
35
|
}
|
|
37
36
|
},
|
|
37
|
+
"main": "./dist/index.cjs",
|
|
38
|
+
"module": "./dist/index.mjs",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
38
40
|
"files": [
|
|
39
41
|
"dist/",
|
|
40
42
|
"tsconfig.json",
|
|
@@ -59,8 +61,8 @@
|
|
|
59
61
|
"autofix:rest": "prettier --ignore-path .gitignore --ignore-unknown --write .",
|
|
60
62
|
"autofix": "run-s autofix:*",
|
|
61
63
|
"test:lib": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
62
|
-
"test:ext": "cd test/external/ && bash run-all-tests",
|
|
63
|
-
"test": "
|
|
64
|
+
"test:ext": "npm pack && cd test/external/ && bash run-all-tests",
|
|
65
|
+
"test": "run-s lint test:*",
|
|
64
66
|
"pre-commit": "lint-staged",
|
|
65
67
|
"prepare": "run-s compile && husky install config/husky"
|
|
66
68
|
},
|
|
@@ -97,9 +99,7 @@
|
|
|
97
99
|
"@typescript-eslint/consistent-indexed-object-style": [
|
|
98
100
|
"error",
|
|
99
101
|
"index-signature"
|
|
100
|
-
]
|
|
101
|
-
"import/no-named-as-default-member": 0,
|
|
102
|
-
"import/no-cycle": 0
|
|
102
|
+
]
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"prettier": {
|
package/readme.md
CHANGED
|
@@ -26,7 +26,7 @@ software and may be more appropriate for some situations:
|
|
|
26
26
|
- [express-brute](https://www.npmjs.com/package/express-brute)
|
|
27
27
|
- [rate-limiter](https://www.npmjs.com/package/express-limiter)
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Installation
|
|
30
30
|
|
|
31
31
|
From the npm registry:
|
|
32
32
|
|
|
@@ -51,19 +51,64 @@ Replace `{version}` with the version of the package that you want to your, e.g.:
|
|
|
51
51
|
|
|
52
52
|
## Usage
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
### Importing
|
|
55
|
+
|
|
56
|
+
This library is provided in ESM as well as CJS forms, and works with both
|
|
57
|
+
Javascript and Typescript projects.
|
|
58
|
+
|
|
59
|
+
**This package requires you to use Node 14 or above.**
|
|
60
|
+
|
|
61
|
+
#### Javascript
|
|
62
|
+
|
|
63
|
+
Import it in a CommonJS project as follows:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const rateLimit = require('express-rate-limit')
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Import it in a ESM project as follows:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import rateLimit from 'express-rate-limit'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Typescript
|
|
76
|
+
|
|
77
|
+
If you are using this library in a Typescript project that outputs CommonJS (no
|
|
78
|
+
`type: module` in `package.json` and `module: commonjs` in `tsconfig.json`), set
|
|
79
|
+
`esModuleInterop` to `true` in the `compilerOptions` of your `tsconfig.json` and
|
|
80
|
+
then import it as follows:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import rateLimit from 'express-rate-limit'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If you cannot set `esModuleInterop` to true, import it as follows instead:
|
|
56
87
|
|
|
57
88
|
```ts
|
|
58
89
|
const rateLimit = require('express-rate-limit')
|
|
59
90
|
```
|
|
60
91
|
|
|
61
|
-
|
|
92
|
+
And use the following to import any types if you need to:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { Store, IncrementResponse, ... } from 'express-rate-limit'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If you are using this library in a Typescript project that outputs ESM
|
|
99
|
+
(`type: module` in `package.json` and `module: esnext` in `tsconfig.json`),
|
|
100
|
+
import it as follows:
|
|
62
101
|
|
|
63
102
|
```ts
|
|
64
103
|
import rateLimit from 'express-rate-limit'
|
|
65
104
|
```
|
|
66
105
|
|
|
106
|
+
And use the following to import any types if you need to:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import rateLimit, { Store, IncrementResponse, ... } from 'express-rate-limit'
|
|
110
|
+
```
|
|
111
|
+
|
|
67
112
|
### Examples
|
|
68
113
|
|
|
69
114
|
To use it in an API-only server where the rate-limiter should be applied to all
|