Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kkoomen/nestjs-throttler-storage-redis
Redis storage provider for the nestjs-throttler package (DEPRECATED)
https://github.com/kkoomen/nestjs-throttler-storage-redis
express fastify graphql nestjs rate-limit redis rpc socketio storage throttler websocket
Last synced: about 2 months ago
JSON representation
Redis storage provider for the nestjs-throttler package (DEPRECATED)
- Host: GitHub
- URL: https://github.com/kkoomen/nestjs-throttler-storage-redis
- Owner: kkoomen
- License: mit
- Archived: true
- Created: 2020-06-06T05:04:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-02T09:58:21.000Z (2 months ago)
- Last Synced: 2024-09-19T04:09:05.492Z (about 2 months ago)
- Topics: express, fastify, graphql, nestjs, rate-limit, redis, rpc, socketio, storage, throttler, websocket
- Language: TypeScript
- Homepage:
- Size: 7.99 MB
- Stars: 151
- Watchers: 6
- Forks: 20
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# NestJS Throttler Redis Storage (DEPRECATED)
:warning: **The original package will be further maintained by @jmcdo29, see [here](https://github.com/jmcdo29/nest-lab/tree/main/packages/throttler-storage-redis), as this repository will not be maintained anymore for future development.**
---
![Tests status](https://img.shields.io/github/actions/workflow/status/kkoomen/nestjs-throttler-storage-redis/tests.yml?label=tests&branch=master)
[![npm](https://img.shields.io/npm/v/nestjs-throttler-storage-redis)](https://www.npmjs.com/package/nestjs-throttler-storage-redis)Redis storage provider for the [@nestjs/throttler](https://github.com/nestjs/throttler) package.
# Installation
### Yarn
- `yarn add nestjs-throttler-storage-redis ioredis`
### NPM
- `npm install --save nestjs-throttler-storage-redis ioredis`
# Usage
Basic usage:
```ts
import { ThrottlerModule, seconds } from '@nestjs/throttler';
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis';
import Redis from 'ioredis';@Module({
imports: [
ThrottlerModule.forRoot({
throttlers: [{ limit: 5, ttl: seconds(60) }],// Below are possible options on how to configure the storage service.
// default config (host = localhost, port = 6379)
storage: new ThrottlerStorageRedisService(),// connection url
storage: new ThrottlerStorageRedisService('redis://'),// redis object
storage: new ThrottlerStorageRedisService(new Redis()),// redis clusters
storage: new ThrottlerStorageRedisService(new Redis.Cluster(nodes, options)),
}),
],
})
export class AppModule {}
```Inject another config module and service:
```ts
import { ThrottlerModule } from '@nestjs/throttler';
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis';@Module({
imports: [
ThrottlerModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
throttlers: [
{
ttl: config.get('THROTTLE_TTL'),
limit: config.get('THROTTLE_LIMIT'),
},
],
storage: new ThrottlerStorageRedisService(),
}),
}),
],
})
export class AppModule {}
```# Issues
Bugs and features related to the redis implementation are welcome in this
repository.# License
NestJS Throttler Redis Storage is licensed under the MIT license.