Comments (3)
Hi @twigs67, I've just installed and configured the module and it successfully works with the following packages:
"ioredis": "^5.3.1",
"nestjs-throttler-storage-redis": "^0.3.0",
"redis": "3",
"@types/ioredis": "^5.0.0",
Here's my storage configuration:
storage: new ThrottlerStorageRedisService(
new Redis({
host: configService.get<string>('REDIS_HOST'),
port: +configService.get<string>('REDIS_PORT'),
password: configService.get<string>('REDIS_PASSWORD'),
db: +configService.get<string>('REDIS_THROTTLER_DB'),
}),
),
from nestjs-throttler-storage-redis.
@twigs67 You can check if rate limiter is working by using redis-cli monitor
in your terminal after you started redis and then you should see an EVAL
, INCR
, PTTL
and PEXIRE
being executed:
Shell 1: redis-server
start redis server
Shell 2: yarn start:dev
start your project
Shell 3: redis-cli monitor
start redis monitoring
Then in shell 4 you can run curl localhost:3000
(assuming your application runs on this address) and then in shell 3 you will see:
1678096891.755335 [0 127.0.0.1:55191] "EVAL" "local totalHits = redis.call(\"INCR\", KEYS[1])\nlocal timeToExpire = redis.call(\"PTTL\", KEYS[1])\nif timeToExpire <= 0\nthen\nredis.call(\"PEXPIRE\", KEYS[1], tonumber(ARGV[1]))\ntimeToExpire = tonumber(ARGV[1])\nend\nreturn { totalHits, timeToExpire }" "1" "8b40547db3793cee1110528738884f6a" "10000"
1678096891.755417 [0 lua] "INCR" "8b40547db3793cee1110528738884f6a"
1678096891.755434 [0 lua] "PTTL" "8b40547db3793cee1110528738884f6a"
1678096891.755443 [0 lua] "PEXPIRE" "8b40547db3793cee1110528738884f6a" "10000"
If you see something to this output, you know the throttler works.
from nestjs-throttler-storage-redis.
Closing due to inactivity.
from nestjs-throttler-storage-redis.
Related Issues (20)
- That is a bad idea to use Redis SCAN command, it works not like you expects... HOT 6
- Request flooding bypasses rate limit to some extend HOT 6
- unable to implement custom guard HOT 1
- WRONGTYPE Operation against a key holding the wrong kind of value HOT 8
- Wrong `timeToExpire` unit HOT 2
- Dynamically update config values of limiter HOT 1
- Redis connection kept open after application shutdown
- @nestjs/throttler v5 ttl unit changed from second to milisecond HOT 4
- connecting with forRootAsync doesn't work HOT 11
- Not working for limit greater than 10_000 HOT 5
- nest 8 compatibility HOT 1
- Problems with Redis storage HOT 1
- Support redis cluster HOT 14
- Issue Fixed in 322 Still Exists HOT 2
- `Maximum call stack size exceeded` error while e2e test my NestJS app HOT 3
- update ioredis to v5
- suggestion: uninstall @types/ioredis
- Update peer dependencies on @nestjs/common and @nestjs/throttler to latest version compatible versions HOT 4
- connect aws ElastiCache with seperate read and write HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-throttler-storage-redis.