@tramvai/module-request-limiter 2.21.1 → 2.24.1
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/README.md +4 -3
- package/lib/requestLimiter.d.ts +1 -2
- package/lib/server.es.js +2 -2
- package/lib/server.js +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -22,19 +22,20 @@ createApp({
|
|
|
22
22
|
modules: [ RequestLimiterModule ],
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
|
+
Request Limiter automatically starts working
|
|
25
26
|
|
|
26
27
|
## Usage
|
|
27
28
|
|
|
28
|
-
###
|
|
29
|
+
### Turn off request limiter
|
|
29
30
|
|
|
30
|
-
To
|
|
31
|
+
To turn off the limiter, use token `REQUESTS_LIMITER_ACTIVATE_TOKEN` with `false` value:
|
|
31
32
|
|
|
32
33
|
```ts
|
|
33
34
|
import { REQUESTS_LIMITER_ACTIVATE_TOKEN } from '@tramvai/module-request-limiter';
|
|
34
35
|
|
|
35
36
|
const provider = {
|
|
36
37
|
provide: REQUESTS_LIMITER_ACTIVATE_TOKEN,
|
|
37
|
-
useValue:
|
|
38
|
+
useValue: false,
|
|
38
39
|
};
|
|
39
40
|
```
|
|
40
41
|
|
package/lib/requestLimiter.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { FastifyRequest, FastifyReply, HookHandlerDoneFunction } from 'fastify';
|
|
3
2
|
export interface RequestLimiterOptions {
|
|
4
3
|
limit?: number;
|
|
@@ -33,4 +32,4 @@ export declare class RequestLimiter {
|
|
|
33
32
|
}
|
|
34
33
|
export declare const fastifyRequestsLimiter: import("fastify").FastifyPluginAsync<{
|
|
35
34
|
requestsLimiter: RequestLimiter;
|
|
36
|
-
}, import("
|
|
35
|
+
}, import("fastify").RawServerDefault>;
|
package/lib/server.es.js
CHANGED
|
@@ -158,7 +158,7 @@ RequestLimiterModule = __decorate([
|
|
|
158
158
|
provide: REQUESTS_LIMITER_TOKEN,
|
|
159
159
|
scope: Scope.SINGLETON,
|
|
160
160
|
useFactory: ({ options, featureEnable }) => {
|
|
161
|
-
if (featureEnable
|
|
161
|
+
if (featureEnable === false) {
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
return new RequestLimiter(options !== null && options !== void 0 ? options : {});
|
|
@@ -173,7 +173,7 @@ RequestLimiterModule = __decorate([
|
|
|
173
173
|
multi: true,
|
|
174
174
|
useFactory: ({ requestsLimiter, featureEnable }) => {
|
|
175
175
|
return async (app) => {
|
|
176
|
-
if (featureEnable
|
|
176
|
+
if (featureEnable === false) {
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
await fastifyRequestsLimiter(app, { requestsLimiter });
|
package/lib/server.js
CHANGED
|
@@ -167,7 +167,7 @@ exports.RequestLimiterModule = tslib.__decorate([
|
|
|
167
167
|
provide: REQUESTS_LIMITER_TOKEN,
|
|
168
168
|
scope: core.Scope.SINGLETON,
|
|
169
169
|
useFactory: ({ options, featureEnable }) => {
|
|
170
|
-
if (featureEnable
|
|
170
|
+
if (featureEnable === false) {
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
173
|
return new RequestLimiter(options !== null && options !== void 0 ? options : {});
|
|
@@ -182,7 +182,7 @@ exports.RequestLimiterModule = tslib.__decorate([
|
|
|
182
182
|
multi: true,
|
|
183
183
|
useFactory: ({ requestsLimiter, featureEnable }) => {
|
|
184
184
|
return async (app) => {
|
|
185
|
-
if (featureEnable
|
|
185
|
+
if (featureEnable === false) {
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
188
|
await fastifyRequestsLimiter(app, { requestsLimiter });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-request-limiter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.1",
|
|
4
4
|
"description": "Enable different rendering modes for pages",
|
|
5
5
|
"main": "lib/server.js",
|
|
6
6
|
"module": "lib/server.es.js",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"registry": "https://registry.npmjs.org/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tinkoff/errors": "0.3.
|
|
27
|
+
"@tinkoff/errors": "0.3.3",
|
|
28
28
|
"fastify-plugin": "^3.0.1",
|
|
29
29
|
"on-finished": "^2.3.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@tinkoff/dippy": "0.8.2",
|
|
34
|
-
"@tramvai/core": "2.
|
|
35
|
-
"@tramvai/tokens-server-private": "2.
|
|
34
|
+
"@tramvai/core": "2.24.1",
|
|
35
|
+
"@tramvai/tokens-server-private": "2.24.1",
|
|
36
36
|
"fastify": "^3.0.0",
|
|
37
37
|
"tslib": "^2.0.3"
|
|
38
38
|
}
|