@fluojs/throttler 1.0.0-beta.5 → 1.0.0-beta.7
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.ko.md +4 -3
- package/README.md +4 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/module.js +1 -1
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -0
- package/package.json +5 -5
package/README.ko.md
CHANGED
|
@@ -122,10 +122,10 @@ ThrottlerModule.forRoot({
|
|
|
122
122
|
## 공개 API 개요
|
|
123
123
|
|
|
124
124
|
### 모듈
|
|
125
|
-
- `ThrottlerModule.forRoot(options)`: throttler
|
|
126
|
-
- 패키지 수준 등록은 `ThrottlerModule.forRoot(options)`를 통해 지원합니다. 내부 프로바이더 조합
|
|
125
|
+
- `ThrottlerModule.forRoot(options)`: 검증된 throttler 옵션과 `ThrottlerGuard`를 모듈 그래프에 제공합니다.
|
|
126
|
+
- 패키지 수준 등록은 `ThrottlerModule.forRoot(options)`를 통해 지원합니다. 내부 프로바이더 조합 헬퍼와 DI 토큰은 공개 계약에 포함되지 않습니다.
|
|
127
127
|
|
|
128
|
-
`ttl`과 `limit`은 양의 finite integer여야 합니다. `
|
|
128
|
+
`ttl`과 `limit`은 양의 finite integer여야 합니다. `trustProxyHeaders`와 `keyGenerator`로 client identity를 조정할 수 있습니다. `store` 옵션을 제공하지 않으면 각 `ThrottlerGuard` 인스턴스가 자체 in-memory store를 소유합니다. 저장소를 공유하거나 외부에서 관리해야 한다면 `RedisThrottlerStore` 같은 `ThrottlerStore` 구현을 전달하세요.
|
|
129
129
|
|
|
130
130
|
### 데코레이터
|
|
131
131
|
- `@Throttle({ ttl, limit })`: 클래스나 메서드에 특정 속도 제한을 설정합니다.
|
|
@@ -138,6 +138,7 @@ ThrottlerModule.forRoot({
|
|
|
138
138
|
- `createMemoryThrottlerStore()`: 간단한 메모리 내 저장소를 생성합니다 (기본값).
|
|
139
139
|
- `RedisThrottlerStore`: Redis용 저장소 어댑터입니다.
|
|
140
140
|
- `ThrottlerStore`: custom store를 위한 공개 계약입니다.
|
|
141
|
+
- `ThrottlerConsumeInput`: custom store가 guard의 현재 시간과 TTL window를 공유할 수 있도록 `ThrottlerStore.consume(key, input)`에 전달되는 공개 입력 shape입니다.
|
|
141
142
|
|
|
142
143
|
### status와 diagnostics
|
|
143
144
|
- `createThrottlerPlatformStatusSnapshot(...)`: 플랫폼 status snapshot을 생성합니다.
|
package/README.md
CHANGED
|
@@ -122,10 +122,10 @@ ThrottlerModule.forRoot({
|
|
|
122
122
|
## Public API Overview
|
|
123
123
|
|
|
124
124
|
### Modules
|
|
125
|
-
- `ThrottlerModule.forRoot(options)`: Provides throttler options
|
|
126
|
-
- Package-level registration is supported through `ThrottlerModule.forRoot(options)`. Internal provider-composition helpers are not part of the public contract.
|
|
125
|
+
- `ThrottlerModule.forRoot(options)`: Provides validated throttler options and `ThrottlerGuard` to the module graph.
|
|
126
|
+
- Package-level registration is supported through `ThrottlerModule.forRoot(options)`. Internal provider-composition helpers and DI tokens are not part of the public contract.
|
|
127
127
|
|
|
128
|
-
`ttl` and `limit` must be positive finite integers. `
|
|
128
|
+
`ttl` and `limit` must be positive finite integers. `trustProxyHeaders` and `keyGenerator` customize client identity. If no `store` option is supplied, each `ThrottlerGuard` instance owns its own in-memory store; pass a `ThrottlerStore` implementation such as `RedisThrottlerStore` when storage must be shared or externally managed.
|
|
129
129
|
|
|
130
130
|
### Decorators
|
|
131
131
|
- `@Throttle({ ttl, limit })`: Sets a specific rate limit for a class or method.
|
|
@@ -138,6 +138,7 @@ ThrottlerModule.forRoot({
|
|
|
138
138
|
- `createMemoryThrottlerStore()`: Creates a simple in-memory store (default).
|
|
139
139
|
- `RedisThrottlerStore`: Store adapter for Redis.
|
|
140
140
|
- `ThrottlerStore`: Public contract for custom stores.
|
|
141
|
+
- `ThrottlerConsumeInput`: Public input shape passed to `ThrottlerStore.consume(key, input)` so custom stores can share the guard's current time and TTL window.
|
|
141
142
|
|
|
142
143
|
### Status and diagnostics
|
|
143
144
|
- `createThrottlerPlatformStatusSnapshot(...)`: Creates a platform status snapshot.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ export { RedisThrottlerStore } from './redis-store.js';
|
|
|
4
4
|
export * from './module.js';
|
|
5
5
|
export * from './status.js';
|
|
6
6
|
export { createMemoryThrottlerStore } from './store.js';
|
|
7
|
-
export {
|
|
8
|
-
export type { ThrottlerHandlerOptions, ThrottlerModuleOptions, ThrottlerStore, ThrottlerStoreEntry } from './types.js';
|
|
7
|
+
export type { ThrottlerConsumeInput, ThrottlerHandlerOptions, ThrottlerModuleOptions, ThrottlerStore, ThrottlerStoreEntry, } from './types.js';
|
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,4 @@ export { ThrottlerGuard } from './guard.js';
|
|
|
3
3
|
export { RedisThrottlerStore } from './redis-store.js';
|
|
4
4
|
export * from './module.js';
|
|
5
5
|
export * from './status.js';
|
|
6
|
-
export { createMemoryThrottlerStore } from './store.js';
|
|
7
|
-
export { THROTTLER_OPTIONS } from './tokens.js';
|
|
6
|
+
export { createMemoryThrottlerStore } from './store.js';
|
package/dist/module.js
CHANGED
|
@@ -39,7 +39,7 @@ export class ThrottlerModule {
|
|
|
39
39
|
class ThrottlerRootModule extends ThrottlerModule {}
|
|
40
40
|
return defineModule(ThrottlerRootModule, {
|
|
41
41
|
exports: [ThrottlerGuard],
|
|
42
|
-
global: true,
|
|
42
|
+
global: options.global ?? true,
|
|
43
43
|
providers: createThrottlerProviders(options)
|
|
44
44
|
});
|
|
45
45
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,10 +7,16 @@ export interface ThrottlerStoreEntry {
|
|
|
7
7
|
resetAt: number;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Public input passed to a `ThrottlerStore` when consuming a request slot.
|
|
11
|
+
*
|
|
12
|
+
* @remarks `ThrottlerGuard` passes this shape to `ThrottlerStore.consume(...)`
|
|
13
|
+
* so custom stores can anchor the current window to the guard's clock and the
|
|
14
|
+
* resolved module or route-level TTL.
|
|
11
15
|
*/
|
|
12
16
|
export interface ThrottlerConsumeInput {
|
|
17
|
+
/** Current epoch time in milliseconds for the consume operation. */
|
|
13
18
|
now: number;
|
|
19
|
+
/** Rate-limit window length in seconds. */
|
|
14
20
|
ttlSeconds: number;
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
@@ -32,6 +38,8 @@ export interface ThrottlerHandlerOptions {
|
|
|
32
38
|
* Public configuration options for `ThrottlerModule.forRoot(...)`.
|
|
33
39
|
*/
|
|
34
40
|
export interface ThrottlerModuleOptions {
|
|
41
|
+
/** Whether throttler providers should be visible globally. Defaults to `true`. */
|
|
42
|
+
global?: boolean;
|
|
35
43
|
/** Seconds in the rate-limit window (module-wide default). */
|
|
36
44
|
ttl: number;
|
|
37
45
|
/** Maximum number of requests allowed within the window (module-wide default). */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACxG;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAAC;IAClD,+DAA+D;IAC/D,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB"}
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAoBvG;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAOjG;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAoBvG;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAOjG;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB,CAatG;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAQ3F"}
|
package/dist/validation.js
CHANGED
|
@@ -37,8 +37,10 @@ export function validateThrottleOptions(options) {
|
|
|
37
37
|
*/
|
|
38
38
|
export function validateThrottlerModuleOptions(options) {
|
|
39
39
|
validateThrottleOptions(options);
|
|
40
|
+
assertOptionalBoolean(options.global, 'global');
|
|
40
41
|
assertOptionalBoolean(options.trustProxyHeaders, 'trustProxyHeaders');
|
|
41
42
|
return {
|
|
43
|
+
global: options.global,
|
|
42
44
|
keyGenerator: options.keyGenerator,
|
|
43
45
|
limit: options.limit,
|
|
44
46
|
store: options.store,
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"redis",
|
|
10
10
|
"decorator"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.7",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@fluojs/core": "^1.0.0-beta.
|
|
40
|
-
"@fluojs/di": "^1.0.0-beta.6",
|
|
39
|
+
"@fluojs/core": "^1.0.0-beta.5",
|
|
41
40
|
"@fluojs/http": "^1.0.0-beta.10",
|
|
42
|
-
"@fluojs/runtime": "^1.0.0-beta.
|
|
41
|
+
"@fluojs/runtime": "^1.0.0-beta.12",
|
|
42
|
+
"@fluojs/di": "^1.0.0-beta.7"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"ioredis": "^5.0.0",
|
|
46
|
-
"@fluojs/redis": "^1.0.0-beta.
|
|
46
|
+
"@fluojs/redis": "^1.0.0-beta.4"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@fluojs/redis": {
|