not-node 6.3.24 → 6.3.26
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/package.json +1 -1
- package/src/form/form.js +6 -2
- package/src/init/lib/rateLimiter.js +4 -0
package/package.json
CHANGED
package/src/form/form.js
CHANGED
|
@@ -57,6 +57,7 @@ class Form {
|
|
|
57
57
|
#rateLimiter = null;
|
|
58
58
|
#rateLimiterIdGetter = (data) => data.identity.sid;
|
|
59
59
|
#rateLimiterException = FormExceptionTooManyRequests;
|
|
60
|
+
#rateLimiterClientName = InitRateLimiter.DEFAULT_CLIENT;
|
|
60
61
|
|
|
61
62
|
constructor({
|
|
62
63
|
FIELDS,
|
|
@@ -116,7 +117,7 @@ class Form {
|
|
|
116
117
|
**/
|
|
117
118
|
async run(req) {
|
|
118
119
|
let data = await this.extract(req);
|
|
119
|
-
this.#checkRate(data);
|
|
120
|
+
await this.#checkRate(data);
|
|
120
121
|
await this.#_validate(data);
|
|
121
122
|
return data;
|
|
122
123
|
}
|
|
@@ -477,6 +478,9 @@ class Form {
|
|
|
477
478
|
if (rate.exception) {
|
|
478
479
|
this.#rateLimiterException = rate.exception;
|
|
479
480
|
}
|
|
481
|
+
if (rate.client && typeof rate.client === "string") {
|
|
482
|
+
this.#rateLimiterClientName = rate.client;
|
|
483
|
+
}
|
|
480
484
|
if (
|
|
481
485
|
rate.options &&
|
|
482
486
|
typeof rate.options == "object" &&
|
|
@@ -484,7 +488,7 @@ class Form {
|
|
|
484
488
|
) {
|
|
485
489
|
this.#rateLimiter = InitRateLimiter.initCustom(
|
|
486
490
|
rate.options,
|
|
487
|
-
|
|
491
|
+
this.#rateLimiterClientName
|
|
488
492
|
);
|
|
489
493
|
}
|
|
490
494
|
}
|
|
@@ -12,6 +12,10 @@ const DEFAULT_OPTIONS = {
|
|
|
12
12
|
const DEFAULT_CLIENT = "ioredis";
|
|
13
13
|
|
|
14
14
|
module.exports = class InitRateLimiter {
|
|
15
|
+
static get DEFAULT_CLIENT() {
|
|
16
|
+
return DEFAULT_CLIENT;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
static createMiddleware({ rateLimiter }) {
|
|
16
20
|
return (req, res, next) => {
|
|
17
21
|
rateLimiter
|