@nestjs/throttler 1.1.3 → 2.0.0

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.
@@ -1,42 +1,53 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1
+ 'use strict';
2
+ var __decorate =
3
+ (this && this.__decorate) ||
4
+ function (decorators, target, key, desc) {
5
+ var c = arguments.length,
6
+ r =
7
+ c < 3
8
+ ? target
9
+ : desc === null
10
+ ? (desc = Object.getOwnPropertyDescriptor(target, key))
11
+ : desc,
12
+ d;
13
+ if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
14
+ r = Reflect.decorate(decorators, target, key, desc);
15
+ else
16
+ for (var i = decorators.length - 1; i >= 0; i--)
17
+ if ((d = decorators[i]))
18
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
19
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
20
+ };
21
+ Object.defineProperty(exports, '__esModule', { value: true });
9
22
  exports.ThrottlerStorageService = void 0;
10
- const common_1 = require("@nestjs/common");
23
+ const common_1 = require('@nestjs/common');
11
24
  let ThrottlerStorageService = class ThrottlerStorageService {
12
- constructor() {
13
- this._storage = {};
14
- this.timeoutIds = [];
15
- }
16
- get storage() {
17
- return this._storage;
18
- }
19
- async getRecord(key) {
20
- return this.storage[key] || [];
21
- }
22
- async addRecord(key, ttl) {
23
- const ttlMilliseconds = ttl * 1000;
24
- if (!this.storage[key]) {
25
- this.storage[key] = [];
26
- }
27
- this.storage[key].push(Date.now() + ttlMilliseconds);
28
- const timeoutId = setTimeout(() => {
29
- this.storage[key].shift();
30
- clearTimeout(timeoutId);
31
- }, ttlMilliseconds);
32
- this.timeoutIds.push(timeoutId);
33
- }
34
- onApplicationShutdown() {
35
- this.timeoutIds.forEach(clearTimeout);
25
+ constructor() {
26
+ this._storage = {};
27
+ this.timeoutIds = [];
28
+ }
29
+ get storage() {
30
+ return this._storage;
31
+ }
32
+ async getRecord(key) {
33
+ return this.storage[key] || [];
34
+ }
35
+ async addRecord(key, ttl) {
36
+ const ttlMilliseconds = ttl * 1000;
37
+ if (!this.storage[key]) {
38
+ this.storage[key] = [];
36
39
  }
40
+ this.storage[key].push(Date.now() + ttlMilliseconds);
41
+ const timeoutId = setTimeout(() => {
42
+ this.storage[key].shift();
43
+ clearTimeout(timeoutId);
44
+ }, ttlMilliseconds);
45
+ this.timeoutIds.push(timeoutId);
46
+ }
47
+ onApplicationShutdown() {
48
+ this.timeoutIds.forEach(clearTimeout);
49
+ }
37
50
  };
38
- ThrottlerStorageService = __decorate([
39
- common_1.Injectable()
40
- ], ThrottlerStorageService);
51
+ ThrottlerStorageService = __decorate([common_1.Injectable()], ThrottlerStorageService);
41
52
  exports.ThrottlerStorageService = ThrottlerStorageService;
42
- //# sourceMappingURL=throttler.service.js.map
53
+ //# sourceMappingURL=throttler.service.js.map