@@ -58,57 +58,19 @@ Javascript and Typescript projects.
58
58
59
59
** This package requires you to use Node 14 or above.**
60
60
61
- #### Javascript
62
-
63
- Import it in a CommonJS project as follows:
61
+ Import it in a CommonJS project (` type: commonjs ` or no ` type ` field in
62
+ ` package.json ` ) as follows:
64
63
65
64
``` ts
66
65
const rateLimit = require (' express-rate-limit' )
67
66
```
68
67
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:
68
+ Import it in a ESM project (` type: module ` in ` package.json ` ) as follows:
81
69
82
70
``` ts
83
71
import rateLimit from ' express-rate-limit'
84
72
```
85
73
86
- If you cannot set ` esModuleInterop ` to true, import it as follows instead:
87
-
88
- ``` ts
89
- const rateLimit = require (' express-rate-limit' )
90
- ```
91
-
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:
101
-
102
- ``` ts
103
- import rateLimit from ' express-rate-limit'
104
- ```
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
-
112
74
### Examples
113
75
114
76
To use it in an API-only server where the rate-limiter should be applied to all
0 commit comments