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

Throttle records the same with 2 routes. #7

Closed
jericopulvera opened this issue Jul 20, 2018 · 1 comment
Closed

Throttle records the same with 2 routes. #7

jericopulvera opened this issue Jul 20, 2018 · 1 comment

Comments

@jericopulvera
Copy link

jericopulvera commented Jul 20, 2018

Hi. I have this 2 route but I want the request record on them to be the same.

    Route.post('raffles-like', 'RaffleLikeController.store').middleware([
        'customAuth', 'throttle:20,30'
    ])
    Route.delete('raffles-like/:productId', 'RaffleLikeController.destroy').middleware([
        'customAuth', 'throttle:20,30'
    ])

What's currently happening is that when I like a product and reach the throttle limit, I would still be able to, unlike the product.

What I want to happen is that when Liking throttle limit is reached it should be the same with unlike.

Like this.

    Route.post('raffles-like', 'RaffleLikeController.store').middleware([
        'customAuth', 'throttle-like:20,30'
    ])
    Route.delete('raffles-like/:productId', 'RaffleLikeController.destroy').middleware([
        'customAuth', 'throttle-like:20,30'
    ])

How do I achieve this?

@masasron
Copy link
Owner

Hi @jericopulvera,

I currently generate a signature for each route like so request method + path + user IP.
https://github.com/masasron/adonis-throttle/blob/master/middleware/ThrottleRequests.js#L71

You can overwrite this value when by using the Throttle object directly.
https://github.com/masasron/adonis-throttle#advance

I would just create a new middleware that removes the request method from the signature.

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

No branches or pull requests

2 participants