@nestjs-redisx/idempotency
v1.0.2
Published
Idempotency plugin for NestJS RedisX with request deduplication and response replay
Maintainers
Readme
@nestjs-redisx/idempotency
HTTP idempotency plugin for NestJS RedisX. Prevents duplicate request processing using the @Idempotent decorator with fingerprint validation and automatic response replay.
Installation
npm install @nestjs-redisx/core @nestjs-redisx/idempotency ioredisQuick Example
import { RedisModule } from '@nestjs-redisx/core';
import { IdempotencyPlugin, Idempotent } from '@nestjs-redisx/idempotency';
@Module({
imports: [
RedisModule.forRoot({
clients: { host: 'localhost', port: 6379 },
plugins: [new IdempotencyPlugin({ defaultTtl: 86400 })],
}),
],
})
export class AppModule {}
@Controller('payments')
export class PaymentsController {
@Post()
@Idempotent({ ttl: 3600 })
async createPayment(@Body() dto: CreatePaymentDto) {
// Executes once per Idempotency-Key header, replays cached response after
return this.paymentsService.create(dto);
}
}Documentation
Full documentation: nestjs-redisx.dev/en/reference/idempotency/
License
MIT
