Expand description
NestJS @nestjs/idempotency analogue —
Idempotency-Key request deduplication.
§Behavior
- Missing key → pass through (or 400 if
IdempotencyOptions::required). - Completed key → replay stored status/body with header
idempotency-replayed: true. - In-flight key → 409 (
IDEMPOTENCY_IN_FLIGHT). - First writer → run handler, then
IdempotencyStore::complete.
§Security
Always set IdempotencyOptions::scope to the authenticated principal so tenants cannot
replay another user’s response. Prefer Redis TTL in multi-instance deploys (cache-redis).
§Middleware
ⓘ
use axum::middleware::from_fn_with_state;
use nestrs_idempotency::{idempotency_middleware, IdempotencyOptions};
use std::sync::Arc;
let opts = Arc::new(IdempotencyOptions::default());
let router = router.layer(from_fn_with_state(opts, idempotency_middleware));Umbrella feature: nestrs / idempotency → nestrs::idempotency.
Structs§
- Dynamic
Module - Runtime-composed module unit for conditional imports (feature flags, env switches, plugins).
- Idempotency
Module - Idempotency
Options - Idempotency
Record - InMemory
Idempotency Store - Provider
Registry
Traits§
- Idempotency
Store - Injectable
- Application service or provider type constructed through the DI container.
Functions§
- idempotency_
middleware - Axum middleware: replay stored responses for repeated
Idempotency-Keyvalues.