@edirect/rate-limit-module 11.0.48 → 11.0.49
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 +109 -36
- package/dist/README.md +109 -36
- package/dist/package.json +3 -3
- package/dist/src/rate-limiting.module.d.ts +3 -0
- package/dist/src/rate-limiting.module.d.ts.map +1 -1
- package/dist/src/rate-limiting.module.js +17 -22
- package/dist/src/rules/rule.module.d.ts +1 -1
- package/dist/src/rules/rule.module.d.ts.map +1 -1
- package/dist/src/rules/rule.module.js +10 -12
- package/dist/src/shared/dsl/dsl.service.d.ts.map +1 -1
- package/dist/src/shared/rule-engine/rule-engine.module.d.ts.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,80 +12,153 @@ npm install @edirect/rate-limit-module
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## 🚀 Quick Start
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- Define rate-limiting rules with custom expressions.
|
|
20
|
-
|
|
21
|
-
- Dynamically inject context-aware functions for rule evaluation.
|
|
17
|
+
### 1. Create a Global Database Connection Module
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
**Important:** This module requires a MongoDB connection provider. Create a global module to provide it:
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
```ts
|
|
22
|
+
// db-provider.module.ts
|
|
23
|
+
import { Global, Module } from '@nestjs/common';
|
|
24
|
+
import { Connection } from 'mongoose';
|
|
25
|
+
import { MongoDBConnection } from './mongodb-connection';
|
|
26
|
+
|
|
27
|
+
export const dbProvider = [
|
|
28
|
+
{
|
|
29
|
+
provide: 'DATABASE_CONNECTION',
|
|
30
|
+
useFactory: async (): Promise<Connection> => {
|
|
31
|
+
return new MongoDBConnection().connect();
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
];
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
@Global()
|
|
37
|
+
@Module({
|
|
38
|
+
providers: [...dbProvider],
|
|
39
|
+
exports: [...dbProvider],
|
|
40
|
+
})
|
|
41
|
+
export class DbProviderModule {}
|
|
42
|
+
```
|
|
30
43
|
|
|
31
|
-
2.
|
|
44
|
+
### 2. Import Database Module in Root Module
|
|
32
45
|
|
|
33
|
-
|
|
46
|
+
```ts
|
|
47
|
+
// app.module.ts
|
|
48
|
+
import { Module } from '@nestjs/common';
|
|
49
|
+
import { DbProviderModule } from './db-provider.module';
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
@Module({
|
|
52
|
+
imports: [
|
|
53
|
+
DbProviderModule, // Must be imported first
|
|
54
|
+
// ... other modules
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
export class AppModule {}
|
|
58
|
+
```
|
|
36
59
|
|
|
37
|
-
###
|
|
60
|
+
### 3. Import RateLimitingModule in Feature Module
|
|
38
61
|
|
|
39
62
|
```ts
|
|
63
|
+
import {
|
|
64
|
+
RateLimitingModule,
|
|
65
|
+
RuleEngineModule,
|
|
66
|
+
} from '@edirect/rate-limit-module';
|
|
67
|
+
|
|
40
68
|
@Module({
|
|
41
69
|
imports: [
|
|
42
|
-
|
|
70
|
+
// Pass the token name of your existing MongoDB connection provider
|
|
71
|
+
// Default is 'DATABASE_CONNECTION'
|
|
72
|
+
RateLimitingModule.forRoot('DATABASE_CONNECTION'),
|
|
73
|
+
|
|
74
|
+
// Or use a custom token
|
|
75
|
+
RateLimitingModule.forRoot('MY_CUSTOM_DB_CONNECTION'),
|
|
43
76
|
|
|
77
|
+
// Or omit to use default
|
|
78
|
+
RateLimitingModule.forRoot(),
|
|
79
|
+
|
|
80
|
+
// Configure custom functions for rule evaluation
|
|
44
81
|
RuleEngineModule.forFeatureAsync({
|
|
45
|
-
|
|
46
|
-
|
|
82
|
+
imports: [YourFunctionsModule],
|
|
83
|
+
useFactory: async (useCase: YourInjectFunctionsUseCase) => {
|
|
84
|
+
return await useCase.getFunctions();
|
|
47
85
|
},
|
|
48
|
-
|
|
49
|
-
inject: [QuoteService],
|
|
86
|
+
inject: [YourInjectFunctionsUseCase],
|
|
50
87
|
}),
|
|
51
88
|
],
|
|
52
89
|
})
|
|
53
90
|
export class YourFeatureModule {}
|
|
54
91
|
```
|
|
55
92
|
|
|
56
|
-
|
|
93
|
+
### 2. Database Connection Requirement
|
|
57
94
|
|
|
58
|
-
|
|
95
|
+
The module uses the global `DATABASE_CONNECTION` provider created in step 1. It references your connection using the token name, so it doesn't duplicate the connection.
|
|
96
|
+
|
|
97
|
+
### 3. Apply Rate Limiting to Routes
|
|
98
|
+
|
|
99
|
+
Use the `@RateLimitingRuleMetadata` decorator and `@UseGuards(RateLimitingRuleGuard)` to protect your endpoints:
|
|
59
100
|
|
|
60
101
|
```ts
|
|
102
|
+
import { RateLimitingRuleGuard, RateLimitingRuleMetadata } from '@edirect/rate-limit-module';
|
|
61
103
|
|
|
62
|
-
|
|
104
|
+
@RateLimitingRuleMetadata({
|
|
105
|
+
action: 'create_quote',
|
|
106
|
+
partnerPath: 'partner.partnerId',
|
|
107
|
+
providerPath: 'provider',
|
|
108
|
+
productTypePath: 'productType',
|
|
109
|
+
marketPath: 'market',
|
|
110
|
+
})
|
|
111
|
+
@UseGuards(RateLimitingRuleGuard)
|
|
112
|
+
@Post('quotes')
|
|
113
|
+
createQuote(@Body() body: CreateQuoteDto) {
|
|
114
|
+
return this.quoteService.create(body);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
63
117
|
|
|
118
|
+
## ✨ Features
|
|
64
119
|
|
|
120
|
+
- Define rate-limiting rules with custom expressions
|
|
121
|
+
- Dynamically inject context-aware functions for rule evaluation
|
|
122
|
+
- Easily integrate with any resource via decorators
|
|
123
|
+
- Uses existing MongoDB connection (no separate connection required)
|
|
124
|
+
- Global module - configure once, use everywhere
|
|
125
|
+
- Built with extensibility and modularity in mind
|
|
65
126
|
|
|
66
|
-
|
|
127
|
+
## 🧱 How It Works
|
|
67
128
|
|
|
68
|
-
|
|
129
|
+
1. You define a rule using a simple expression (e.g., `count_quote( ) > 1`)
|
|
130
|
+
2. The rule is evaluated at runtime using data injected from the request context
|
|
131
|
+
3. If the expression is true, the action is blocked
|
|
69
132
|
|
|
70
|
-
|
|
133
|
+
## 🛠 Architecture
|
|
71
134
|
|
|
72
|
-
|
|
135
|
+
The module is designed to:
|
|
73
136
|
|
|
74
|
-
|
|
137
|
+
- **Not create its own MongoDB connection** - it uses the application's existing connection
|
|
138
|
+
- **Be a global module** - providers are available throughout the application
|
|
139
|
+
- **Use custom model providers** - creates Mongoose models using the injected `DATABASE_CONNECTION`
|
|
140
|
+
- **Export Reflector** - ensures guards have access to metadata
|
|
75
141
|
|
|
76
|
-
|
|
142
|
+
## 📝 Configuration Details
|
|
77
143
|
|
|
78
|
-
|
|
144
|
+
### Module Structure
|
|
79
145
|
|
|
80
|
-
|
|
146
|
+
```ts
|
|
147
|
+
RateLimitingModule.forRoot(dbProvider) // Global module, accepts DATABASE_CONNECTION provider
|
|
148
|
+
└─ RuleModule.register() // Provides RuleService and RuleRepository
|
|
149
|
+
└─ Custom Model Provider // Uses DATABASE_CONNECTION to create Mongoose models
|
|
150
|
+
```
|
|
81
151
|
|
|
82
|
-
|
|
152
|
+
### Required Providers
|
|
83
153
|
|
|
84
|
-
|
|
154
|
+
The module requires:
|
|
85
155
|
|
|
86
|
-
|
|
156
|
+
1. **DATABASE_CONNECTION**: Mongoose connection instance
|
|
157
|
+
2. **Reflector**: For metadata reflection (provided by the module)
|
|
158
|
+
3. **RuleService**: For accessing rate limiting rules (exported by RuleModule)
|
|
87
159
|
|
|
88
|
-
|
|
160
|
+
````ts
|
|
161
|
+
import { RateLimitingRuleMetadata } from 'path-to-rate-limiting-module';
|
|
89
162
|
|
|
90
163
|
- `action`: Name of the action to be controlled.
|
|
91
164
|
|
|
@@ -109,7 +182,7 @@ RuleEngineModule.forFeatureAsync({
|
|
|
109
182
|
|
|
110
183
|
inject: [RateLimitingInjectFunctionsUseCase],
|
|
111
184
|
});
|
|
112
|
-
|
|
185
|
+
````
|
|
113
186
|
|
|
114
187
|
## 🧪 Example Rule
|
|
115
188
|
|
package/dist/README.md
CHANGED
|
@@ -12,80 +12,153 @@ npm install @edirect/rate-limit-module
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## 🚀 Quick Start
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- Define rate-limiting rules with custom expressions.
|
|
20
|
-
|
|
21
|
-
- Dynamically inject context-aware functions for rule evaluation.
|
|
17
|
+
### 1. Create a Global Database Connection Module
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
**Important:** This module requires a MongoDB connection provider. Create a global module to provide it:
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
```ts
|
|
22
|
+
// db-provider.module.ts
|
|
23
|
+
import { Global, Module } from '@nestjs/common';
|
|
24
|
+
import { Connection } from 'mongoose';
|
|
25
|
+
import { MongoDBConnection } from './mongodb-connection';
|
|
26
|
+
|
|
27
|
+
export const dbProvider = [
|
|
28
|
+
{
|
|
29
|
+
provide: 'DATABASE_CONNECTION',
|
|
30
|
+
useFactory: async (): Promise<Connection> => {
|
|
31
|
+
return new MongoDBConnection().connect();
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
];
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
@Global()
|
|
37
|
+
@Module({
|
|
38
|
+
providers: [...dbProvider],
|
|
39
|
+
exports: [...dbProvider],
|
|
40
|
+
})
|
|
41
|
+
export class DbProviderModule {}
|
|
42
|
+
```
|
|
30
43
|
|
|
31
|
-
2.
|
|
44
|
+
### 2. Import Database Module in Root Module
|
|
32
45
|
|
|
33
|
-
|
|
46
|
+
```ts
|
|
47
|
+
// app.module.ts
|
|
48
|
+
import { Module } from '@nestjs/common';
|
|
49
|
+
import { DbProviderModule } from './db-provider.module';
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
@Module({
|
|
52
|
+
imports: [
|
|
53
|
+
DbProviderModule, // Must be imported first
|
|
54
|
+
// ... other modules
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
export class AppModule {}
|
|
58
|
+
```
|
|
36
59
|
|
|
37
|
-
###
|
|
60
|
+
### 3. Import RateLimitingModule in Feature Module
|
|
38
61
|
|
|
39
62
|
```ts
|
|
63
|
+
import {
|
|
64
|
+
RateLimitingModule,
|
|
65
|
+
RuleEngineModule,
|
|
66
|
+
} from '@edirect/rate-limit-module';
|
|
67
|
+
|
|
40
68
|
@Module({
|
|
41
69
|
imports: [
|
|
42
|
-
|
|
70
|
+
// Pass the token name of your existing MongoDB connection provider
|
|
71
|
+
// Default is 'DATABASE_CONNECTION'
|
|
72
|
+
RateLimitingModule.forRoot('DATABASE_CONNECTION'),
|
|
73
|
+
|
|
74
|
+
// Or use a custom token
|
|
75
|
+
RateLimitingModule.forRoot('MY_CUSTOM_DB_CONNECTION'),
|
|
43
76
|
|
|
77
|
+
// Or omit to use default
|
|
78
|
+
RateLimitingModule.forRoot(),
|
|
79
|
+
|
|
80
|
+
// Configure custom functions for rule evaluation
|
|
44
81
|
RuleEngineModule.forFeatureAsync({
|
|
45
|
-
|
|
46
|
-
|
|
82
|
+
imports: [YourFunctionsModule],
|
|
83
|
+
useFactory: async (useCase: YourInjectFunctionsUseCase) => {
|
|
84
|
+
return await useCase.getFunctions();
|
|
47
85
|
},
|
|
48
|
-
|
|
49
|
-
inject: [QuoteService],
|
|
86
|
+
inject: [YourInjectFunctionsUseCase],
|
|
50
87
|
}),
|
|
51
88
|
],
|
|
52
89
|
})
|
|
53
90
|
export class YourFeatureModule {}
|
|
54
91
|
```
|
|
55
92
|
|
|
56
|
-
|
|
93
|
+
### 2. Database Connection Requirement
|
|
57
94
|
|
|
58
|
-
|
|
95
|
+
The module uses the global `DATABASE_CONNECTION` provider created in step 1. It references your connection using the token name, so it doesn't duplicate the connection.
|
|
96
|
+
|
|
97
|
+
### 3. Apply Rate Limiting to Routes
|
|
98
|
+
|
|
99
|
+
Use the `@RateLimitingRuleMetadata` decorator and `@UseGuards(RateLimitingRuleGuard)` to protect your endpoints:
|
|
59
100
|
|
|
60
101
|
```ts
|
|
102
|
+
import { RateLimitingRuleGuard, RateLimitingRuleMetadata } from '@edirect/rate-limit-module';
|
|
61
103
|
|
|
62
|
-
|
|
104
|
+
@RateLimitingRuleMetadata({
|
|
105
|
+
action: 'create_quote',
|
|
106
|
+
partnerPath: 'partner.partnerId',
|
|
107
|
+
providerPath: 'provider',
|
|
108
|
+
productTypePath: 'productType',
|
|
109
|
+
marketPath: 'market',
|
|
110
|
+
})
|
|
111
|
+
@UseGuards(RateLimitingRuleGuard)
|
|
112
|
+
@Post('quotes')
|
|
113
|
+
createQuote(@Body() body: CreateQuoteDto) {
|
|
114
|
+
return this.quoteService.create(body);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
63
117
|
|
|
118
|
+
## ✨ Features
|
|
64
119
|
|
|
120
|
+
- Define rate-limiting rules with custom expressions
|
|
121
|
+
- Dynamically inject context-aware functions for rule evaluation
|
|
122
|
+
- Easily integrate with any resource via decorators
|
|
123
|
+
- Uses existing MongoDB connection (no separate connection required)
|
|
124
|
+
- Global module - configure once, use everywhere
|
|
125
|
+
- Built with extensibility and modularity in mind
|
|
65
126
|
|
|
66
|
-
|
|
127
|
+
## 🧱 How It Works
|
|
67
128
|
|
|
68
|
-
|
|
129
|
+
1. You define a rule using a simple expression (e.g., `count_quote( ) > 1`)
|
|
130
|
+
2. The rule is evaluated at runtime using data injected from the request context
|
|
131
|
+
3. If the expression is true, the action is blocked
|
|
69
132
|
|
|
70
|
-
|
|
133
|
+
## 🛠 Architecture
|
|
71
134
|
|
|
72
|
-
|
|
135
|
+
The module is designed to:
|
|
73
136
|
|
|
74
|
-
|
|
137
|
+
- **Not create its own MongoDB connection** - it uses the application's existing connection
|
|
138
|
+
- **Be a global module** - providers are available throughout the application
|
|
139
|
+
- **Use custom model providers** - creates Mongoose models using the injected `DATABASE_CONNECTION`
|
|
140
|
+
- **Export Reflector** - ensures guards have access to metadata
|
|
75
141
|
|
|
76
|
-
|
|
142
|
+
## 📝 Configuration Details
|
|
77
143
|
|
|
78
|
-
|
|
144
|
+
### Module Structure
|
|
79
145
|
|
|
80
|
-
|
|
146
|
+
```ts
|
|
147
|
+
RateLimitingModule.forRoot(dbProvider) // Global module, accepts DATABASE_CONNECTION provider
|
|
148
|
+
└─ RuleModule.register() // Provides RuleService and RuleRepository
|
|
149
|
+
└─ Custom Model Provider // Uses DATABASE_CONNECTION to create Mongoose models
|
|
150
|
+
```
|
|
81
151
|
|
|
82
|
-
|
|
152
|
+
### Required Providers
|
|
83
153
|
|
|
84
|
-
|
|
154
|
+
The module requires:
|
|
85
155
|
|
|
86
|
-
|
|
156
|
+
1. **DATABASE_CONNECTION**: Mongoose connection instance
|
|
157
|
+
2. **Reflector**: For metadata reflection (provided by the module)
|
|
158
|
+
3. **RuleService**: For accessing rate limiting rules (exported by RuleModule)
|
|
87
159
|
|
|
88
|
-
|
|
160
|
+
````ts
|
|
161
|
+
import { RateLimitingRuleMetadata } from 'path-to-rate-limiting-module';
|
|
89
162
|
|
|
90
163
|
- `action`: Name of the action to be controlled.
|
|
91
164
|
|
|
@@ -109,7 +182,7 @@ RuleEngineModule.forFeatureAsync({
|
|
|
109
182
|
|
|
110
183
|
inject: [RateLimitingInjectFunctionsUseCase],
|
|
111
184
|
});
|
|
112
|
-
|
|
185
|
+
````
|
|
113
186
|
|
|
114
187
|
## 🧪 Example Rule
|
|
115
188
|
|
package/dist/package.json
CHANGED
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@edirect/auth": "^11.0.48",
|
|
20
20
|
"@edirect/logger": "^11.0.48",
|
|
21
21
|
"@nestjs/cache-manager": "^3.1.0",
|
|
22
|
-
"@nestjs/common": "^11.1.
|
|
22
|
+
"@nestjs/common": "^11.1.16",
|
|
23
23
|
"@nestjs/config": "^4.0.3",
|
|
24
|
-
"@nestjs/core": "^11.1.
|
|
24
|
+
"@nestjs/core": "^11.1.16",
|
|
25
25
|
"@nestjs/mongoose": "^11.0.4",
|
|
26
26
|
"@nestjs/swagger": "^11.2.6",
|
|
27
27
|
"cache-manager-redis-store": "^3.0.1",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dayjs": "^1.11.19",
|
|
31
31
|
"ioredis": "^5.10.0",
|
|
32
32
|
"jexl": "^2.3.0",
|
|
33
|
-
"mongoose": "^9.
|
|
33
|
+
"mongoose": "^9.3.0",
|
|
34
34
|
"tslib": "^2.8.1",
|
|
35
35
|
"uuid": "^13.0.0"
|
|
36
36
|
},
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
export declare const RATE_LIMIT_DB_CONNECTION = "RATE_LIMIT_DB_CONNECTION";
|
|
1
3
|
export declare class RateLimitingModule {
|
|
4
|
+
static forRoot(connectionToken?: string): DynamicModule;
|
|
2
5
|
}
|
|
3
6
|
//# sourceMappingURL=rate-limiting.module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiting.module.d.ts","sourceRoot":"","sources":["../../src/rate-limiting.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rate-limiting.module.d.ts","sourceRoot":"","sources":["../../src/rate-limiting.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAK/D,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,qBAEa,kBAAkB;IAC7B,MAAM,CAAC,OAAO,CACZ,eAAe,SAAwB,GACtC,aAAa;CASjB"}
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var RateLimitingModule_1;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RateLimitingModule = void 0;
|
|
4
|
+
exports.RateLimitingModule = exports.RATE_LIMIT_DB_CONNECTION = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const
|
|
7
|
-
const mongoose_1 = require("@nestjs/mongoose");
|
|
7
|
+
const core_1 = require("@nestjs/core");
|
|
8
8
|
const rule_module_1 = require("./rules/rule.module");
|
|
9
9
|
const rule_constraint_1 = require("./validators/rule.constraint");
|
|
10
|
-
|
|
10
|
+
exports.RATE_LIMIT_DB_CONNECTION = 'RATE_LIMIT_DB_CONNECTION';
|
|
11
|
+
let RateLimitingModule = RateLimitingModule_1 = class RateLimitingModule {
|
|
12
|
+
static forRoot(connectionToken = 'DATABASE_CONNECTION') {
|
|
13
|
+
return {
|
|
14
|
+
global: true,
|
|
15
|
+
module: RateLimitingModule_1,
|
|
16
|
+
imports: [rule_module_1.RuleModule.register(connectionToken)],
|
|
17
|
+
providers: [core_1.Reflector, rule_constraint_1.IsValidExpressionConstraint],
|
|
18
|
+
exports: [rule_module_1.RuleModule, core_1.Reflector],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
11
21
|
};
|
|
12
22
|
exports.RateLimitingModule = RateLimitingModule;
|
|
13
|
-
exports.RateLimitingModule = RateLimitingModule = tslib_1.__decorate([
|
|
14
|
-
(0, common_1.
|
|
15
|
-
|
|
16
|
-
rule_module_1.RuleModule.register(),
|
|
17
|
-
config_1.ConfigModule.forRoot({
|
|
18
|
-
isGlobal: true,
|
|
19
|
-
}),
|
|
20
|
-
mongoose_1.MongooseModule.forRootAsync({
|
|
21
|
-
imports: [config_1.ConfigModule],
|
|
22
|
-
useFactory: async (config) => ({
|
|
23
|
-
uri: config.get('MONGO_URL'),
|
|
24
|
-
}),
|
|
25
|
-
inject: [config_1.ConfigService],
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
providers: [rule_constraint_1.IsValidExpressionConstraint],
|
|
29
|
-
exports: [rule_module_1.RuleModule],
|
|
30
|
-
})
|
|
23
|
+
exports.RateLimitingModule = RateLimitingModule = RateLimitingModule_1 = tslib_1.__decorate([
|
|
24
|
+
(0, common_1.Global)(),
|
|
25
|
+
(0, common_1.Module)({})
|
|
31
26
|
], RateLimitingModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.module.d.ts","sourceRoot":"","sources":["../../../src/rules/rule.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"rule.module.d.ts","sourceRoot":"","sources":["../../../src/rules/rule.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AASvD,qBACa,UAAU;IACrB,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,aAAa;CAoBxD"}
|
|
@@ -12,22 +12,20 @@ const rule_repository_1 = require("./rule.repository");
|
|
|
12
12
|
const rule_schema_1 = require("./rule.schema");
|
|
13
13
|
const rule_service_1 = require("./rule.service");
|
|
14
14
|
let RuleModule = RuleModule_1 = class RuleModule {
|
|
15
|
-
static register() {
|
|
15
|
+
static register(connectionToken) {
|
|
16
16
|
const enableController = process.env.ENABLE_RATE_LIMITING_RULE_CONTROLLER === 'true';
|
|
17
|
+
const modelProvider = {
|
|
18
|
+
provide: (0, mongoose_1.getModelToken)(rule_schema_1.RateLimitingRule.name),
|
|
19
|
+
useFactory: (connection) => {
|
|
20
|
+
return connection.model(rule_schema_1.RateLimitingRule.name, rule_schema_1.RateLimitingRuleSchema);
|
|
21
|
+
},
|
|
22
|
+
inject: [connectionToken],
|
|
23
|
+
};
|
|
17
24
|
return {
|
|
18
25
|
module: RuleModule_1,
|
|
19
|
-
imports: [
|
|
20
|
-
logger_1.LoggerModule,
|
|
21
|
-
shared_module_1.SharedModule,
|
|
22
|
-
mongoose_1.MongooseModule.forFeature([
|
|
23
|
-
{
|
|
24
|
-
name: rule_schema_1.RateLimitingRule.name,
|
|
25
|
-
schema: rule_schema_1.RateLimitingRuleSchema,
|
|
26
|
-
},
|
|
27
|
-
]),
|
|
28
|
-
],
|
|
26
|
+
imports: [logger_1.LoggerModule, shared_module_1.SharedModule],
|
|
29
27
|
controllers: enableController ? [rule_controller_1.RuleController] : [],
|
|
30
|
-
providers: [rule_service_1.RuleService, rule_repository_1.RuleRepository],
|
|
28
|
+
providers: [modelProvider, rule_service_1.RuleService, rule_repository_1.RuleRepository],
|
|
31
29
|
exports: [rule_service_1.RuleService, rule_repository_1.RuleRepository],
|
|
32
30
|
};
|
|
33
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dsl.service.d.ts","sourceRoot":"","sources":["../../../../src/shared/dsl/dsl.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,qBAAa,UAAU;;IACrB,MAAM,CAAC,WAAW,GAAI,OAAO,aAAa,EAAE,KAAG,SAAS,CAWtD;IAEF,MAAM,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"dsl.service.d.ts","sourceRoot":"","sources":["../../../../src/shared/dsl/dsl.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,qBAAa,UAAU;;IACrB,MAAM,CAAC,WAAW,GAAI,OAAO,aAAa,EAAE,KAAG,SAAS,CAWtD;IAEF,MAAM,CAAC,YAAY,GAAI,QAAQ,SAAS,KAAG,WAAW,CAAC,aAAa,CAAC,CAqDnE;CAuBH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-engine.module.d.ts","sourceRoot":"","sources":["../../../../src/shared/rule-engine/rule-engine.module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"rule-engine.module.d.ts","sourceRoot":"","sources":["../../../../src/shared/rule-engine/rule-engine.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,cAAc,EAEd,yBAAyB,EAE1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,qBAEa,gBAAgB;IAC3B,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE;QAC9B,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG,yBAAyB,CAAC,CAAC;QAC3D,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;KACpC,GAAG,aAAa;IAuBjB,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,aAAa;CAkB7D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/rate-limit-module",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.49",
|
|
4
4
|
"packageScope": "@edirect",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@nestjs/cache-manager": "^3.1.0",
|
|
21
|
-
"@nestjs/common": "^11.1.
|
|
21
|
+
"@nestjs/common": "^11.1.16",
|
|
22
22
|
"@nestjs/config": "^4.0.3",
|
|
23
|
-
"@nestjs/core": "^11.1.
|
|
23
|
+
"@nestjs/core": "^11.1.16",
|
|
24
24
|
"@nestjs/mongoose": "^11.0.4",
|
|
25
25
|
"@nestjs/swagger": "^11.2.6",
|
|
26
26
|
"cache-manager-redis-store": "^3.0.1",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"dayjs": "^1.11.19",
|
|
30
30
|
"ioredis": "^5.10.0",
|
|
31
31
|
"jexl": "^2.3.0",
|
|
32
|
-
"mongoose": "^9.
|
|
32
|
+
"mongoose": "^9.3.0",
|
|
33
33
|
"tslib": "^2.8.1",
|
|
34
34
|
"uuid": "^13.0.0",
|
|
35
|
-
"@edirect/auth": "11.0.
|
|
36
|
-
"@edirect/logger": "11.0.
|
|
35
|
+
"@edirect/auth": "11.0.49",
|
|
36
|
+
"@edirect/logger": "11.0.49"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/jexl": "^2.3.4"
|