Coder Social home page Coder Social logo

Comments (3)

dmolim avatar dmolim commented on May 22, 2024

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.

kkoomen avatar kkoomen commented on May 22, 2024

@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.

kkoomen avatar kkoomen commented on May 22, 2024

Closing due to inactivity.

from nestjs-throttler-storage-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.