RateLimitBehavior
Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.
Defined in: packages/pipeline-rate-limit/src/rate-limit.behavior.ts:87
Pipeline behavior that enforces rate limits before a handler runs.
For each request it consumes points (default 1, or computed per request
when points is a function) from a bucket keyed by
buildRateLimitKey. A cost of 0 charges nothing and skips the
limiter. If the bucket is exhausted it throws
RateLimitExceededError (map to HTTP 429 with
toHttpResponse of @cqrs-ddd/pipeline-rate-limit/http); otherwise the handler proceeds.
context.request is the CQRS command/query/event, not an Express/Fastify
request. Transport metadata needed for keying should be copied into the CQRS
request or written to context.items by an earlier behavior.
Backend-agnostic: it depends only on RateLimiterLike, so any
rate-limiter-flexible backend (memory, Redis/Valkey, Mongo, SQL) is a
one-line swap in the constructor.
Example
Section titled “Example”Per-handler limit, partitioned by tenant and authenticated caller
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RateLimitBehavior(
limiter,defaults?,logger?):RateLimitBehavior
Defined in: packages/pipeline-rate-limit/src/rate-limit.behavior.ts:131
Parameters
Section titled “Parameters”limiter
Section titled “limiter”defaults?
Section titled “defaults?”logger?
Section titled “logger?”Returns
Section titled “Returns”RateLimitBehavior
Properties
Section titled “Properties”[PIPELINE_BEHAVIOR_CONTRACT]
Section titled “[PIPELINE_BEHAVIOR_CONTRACT]”
readonlystatic[PIPELINE_BEHAVIOR_CONTRACT]:IPipelineBehaviorContract
Defined in: packages/pipeline-rate-limit/src/rate-limit.behavior.ts:92
Methods
Section titled “Methods”handle()
Section titled “handle()”handle(
context,next):Promise<unknown>
Defined in: packages/pipeline-rate-limit/src/rate-limit.behavior.ts:146
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”Promise<unknown>
Implementation of
Section titled “Implementation of”resolveEffectiveOptions()
Section titled “resolveEffectiveOptions()”resolveEffectiveOptions(
options?):RateLimitBehaviorOptions
Defined in: packages/pipeline-rate-limit/src/rate-limit.behavior.ts:197
Shallow-merges pipeline-level options over the constructor defaults.