CartoDB / CartoDB-SQL-API

CartoDB SQL API
BSD 3-Clause "New" or "Revised" License
63 stars 63 forks source link

Return 'Retry-after' header when 'Carto-Rate-Limit-Remaining' is 0. #648

Closed mondeja closed 4 years ago

mondeja commented 4 years ago

As was reported in #628, is useful return Retry-after header when Carto-Rate-Limit-Remaining is 0 to avoid force 429 error in order to get seconds remaining until the next permitted call to the API for an user with rate limits enabled.

dgaubert commented 4 years ago

Hi @mondeja!

Thanks for contributing. As per https://github.com/CartoDB/CartoDB-SQL-API#contributing, external contributions must sign a CLA. Let me contact with CARTO's legal department to know how to proceed.

Apart from the legal stuff, the linter is failing because of:

/srv/lib/api/middlewares/rate-limit.js
  34:1   error  Trailing spaces not allowed          no-trailing-spaces
  35:27  error  Expected '===' and instead saw '=='  eqeqeq
✖ 2 problems (2 errors, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

cc/ @oleurud as he's the :brain: behind rate-limiting.