express-rate-limit 6.0.4 → 6.0.5

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 CHANGED
@@ -6,12 +6,32 @@ 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.5](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.5)
10
+
11
+ ### Fixed
12
+
13
+ - Use named imports for ExpressJS types so users do not need to enable the
14
+ `esModuleInterop` flag in their Typescript compiler configuration.
15
+
16
+ ## [6.0.4](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.4)
17
+
18
+ ### Fixed
19
+
20
+ - Upload the built package as a `.tgz` to GitHub releases.
21
+
22
+ ### Changed
23
+
24
+ - Add ` main` and `module` fields to `package.json`. This helps tools such as
25
+ ESLint that do not yet support the `exports` field.
26
+ - Bumped the minimum node.js version in `package-lock.json` to match
27
+ `package.json`
28
+
9
29
  ## [6.0.3](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.3)
10
30
 
11
31
  ### Changed
12
32
 
13
- - Bumped minimum Node version from 12.9 to 14.5 because the transpiled output
14
- uses the nullish coalescing operator (`??`), which
33
+ - Bumped minimum Node version from 12.9 to 14.5 in `package.json` because the
34
+ transpiled output uses the nullish coalescing operator (`??`), which
15
35
  [isn't supported in node.js prior to 14.x](https://node.green/#ES2020-features--nullish-coalescing-operator-----).
16
36
 
17
37
  ## [6.0.2](https://github.com/nfriedly/express-rate-limit/releases/v6.0.2)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- // Generated by dts-bundle-generator v6.2.0
1
+ // Generated by dts-bundle-generator v6.3.0
2
2
 
3
- import Express from 'express';
3
+ import { NextFunction, Request, RequestHandler, Response } from 'express';
4
4
 
5
5
  /**
6
6
  * Callback that fires when a client's hit counter is incremented.
@@ -14,32 +14,32 @@ export declare type IncrementCallback = (error: Error | undefined, totalHits: nu
14
14
  * Method (in the form of middleware) to generate/retrieve a value based on the
15
15
  * incoming request
16
16
  *
17
- * @param request {Express.Request} - The Express request object
18
- * @param response {Express.Response} - The Express response object
17
+ * @param request {Request} - The Express request object
18
+ * @param response {Response} - The Express response object
19
19
  *
20
20
  * @returns {T} - The value needed
21
21
  */
22
- export declare type ValueDeterminingMiddleware<T> = (request: Express.Request, response: Express.Response) => T | Promise<T>;
22
+ export declare type ValueDeterminingMiddleware<T> = (request: Request, response: Response) => T | Promise<T>;
23
23
  /**
24
24
  * Express request handler that sends back a response when a client is
25
25
  * rate-limited.
26
26
  *
27
- * @param request {Express.Request} - The Express request object
28
- * @param response {Express.Response} - The Express response object
29
- * @param next {Express.NextFunction} - The Express `next` function, can be called to skip responding
27
+ * @param request {Request} - The Express request object
28
+ * @param response {Response} - The Express response object
29
+ * @param next {NextFunction} - The Express `next` function, can be called to skip responding
30
30
  * @param optionsUsed {Options} - The options used to set up the middleware
31
31
  */
32
- export declare type RateLimitExceededEventHandler = (request: Express.Request, response: Express.Response, next: Express.NextFunction, optionsUsed: Options) => void;
32
+ export declare type RateLimitExceededEventHandler = (request: Request, response: Response, next: NextFunction, optionsUsed: Options) => void;
33
33
  /**
34
34
  * Event callback that is triggered on a client's first request that exceeds the limit
35
35
  * but not for subsequent requests. May be used for logging, etc. Should *not*
36
36
  * send a response.
37
37
  *
38
- * @param request {Express.Request} - The Express request object
39
- * @param response {Express.Response} - The Express response object
38
+ * @param request {Request} - The Express request object
39
+ * @param response {Response} - The Express response object
40
40
  * @param optionsUsed {Options} - The options used to set up the middleware
41
41
  */
42
- export declare type RateLimitReachedEventHandler = (request: Express.Request, response: Express.Response, optionsUsed: Options) => void;
42
+ export declare type RateLimitReachedEventHandler = (request: Request, response: Response, optionsUsed: Options) => void;
43
43
  /**
44
44
  * Data returned from the `Store` when a client's hit counter is incremented.
45
45
  *
@@ -53,7 +53,7 @@ export declare type IncrementResponse = {
53
53
  /**
54
54
  * A modified Express request handler with the rate limit functions.
55
55
  */
56
- export declare type RateLimitRequestHandler = Express.RequestHandler & {
56
+ export declare type RateLimitRequestHandler = RequestHandler & {
57
57
  /**
58
58
  * Method to reset a client's hit counter.
59
59
  *
@@ -227,7 +227,7 @@ export interface Options {
227
227
  * The extended request object that includes information about the client's
228
228
  * rate limit.
229
229
  */
230
- export declare type AugmentedRequest = Express.Request & {
230
+ export declare type AugmentedRequest = Request & {
231
231
  [key: string]: RateLimitInfo;
232
232
  };
233
233
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-rate-limit",
3
- "version": "6.0.4",
3
+ "version": "6.0.5",
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",
@@ -70,19 +70,19 @@
70
70
  "express": "^4"
71
71
  },
72
72
  "devDependencies": {
73
- "@jest/globals": "^27.4.2",
73
+ "@jest/globals": "^27.4.6",
74
74
  "@types/express": "^4.17.13",
75
- "@types/jest": "^27.0.3",
75
+ "@types/jest": "^27.4.0",
76
76
  "@types/node": "^16.11.17",
77
77
  "@types/supertest": "^2.0.11",
78
78
  "cross-env": "^7.0.3",
79
79
  "del-cli": "^4.0.1",
80
- "dts-bundle-generator": "^6.2.0",
81
- "esbuild": "^0.14.8",
80
+ "dts-bundle-generator": "^6.3.0",
81
+ "esbuild": "^0.14.10",
82
82
  "express": "^4.17.1",
83
83
  "husky": "^7.0.4",
84
- "jest": "^27.4.3",
85
- "lint-staged": "^12.1.2",
84
+ "jest": "^27.4.7",
85
+ "lint-staged": "^12.1.5",
86
86
  "npm-run-all": "^4.1.5",
87
87
  "supertest": "^6.1.6",
88
88
  "ts-jest": "^27.1.1",
package/readme.md CHANGED
@@ -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
package/tsconfig.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
+ "include": ["source/"],
3
+ "exclude": ["node_modules/"],
2
4
  "compilerOptions": {
3
5
  "declaration": true,
4
-
5
6
  "strict": true,
6
7
  "noUnusedLocals": true,
7
8
  "noImplicitReturns": true,
8
9
  "noFallthroughCasesInSwitch": true,
9
-
10
- "moduleResolution": "node",
11
- "esModuleInterop": true
12
- },
13
- "include": ["./source/**/*.ts"],
14
- "exclude": ["./node_modules"]
10
+ "esModuleInterop": true,
11
+ "moduleResolution": "node"
12
+ }
15
13
  }