Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis #16

Closed
kennedyrs opened this issue Jan 28, 2020 · 4 comments · Fixed by #17
Closed

Redis #16

kennedyrs opened this issue Jan 28, 2020 · 4 comments · Fixed by #17

Comments

@kennedyrs
Copy link

kennedyrs commented Jan 28, 2020

When I try to use it with Redis, I have this error

{
  "status": 500,
  "name": "TypeError",
  "message": "this.throttle.store.secondsToExpiration is not a function"
}

Node v12.14.1
Adonis 4.1

is this an error or am I missing something?

@masasron
Copy link
Owner

@AndrewJo could you take a look?

@kennedyrs
Copy link
Author

At file adonis-throttle/middleware/ThrottleRequests.js they try to add a header this.throttle.store.secondsToExpiration(this.throttle.key)

if (!this.throttle.attempt()) {
            this.throttle.incrementExpiration()
            this._addHeaders(
                response,
                maxAttempts,
                this.throttle.remainingAttempts(),
                this.throttle.store.secondsToExpiration(this.throttle.key)
            )
            throw new TooManyRequestsException('Too Many Attempts.')
        }

but at adonis-throttle/src/Drivers/Cache/Redis/index.js this function does not exists

@AndrewJo
Copy link
Contributor

@masasron @kennedyrs submitted PR #17 that fixes this issue!

@masasron
Copy link
Owner

Great, thank you @AndrewJo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants