COP4331-LargeGroupProject-Fall22 / backend

Backend for SmartChef project, see https://github.com/COP4331-LargeGroupProject-Fall22/SmartChef
0 stars 1 forks source link

Implement request rate limiting for the Spoonacular API #26

Closed nashirj closed 1 year ago

nashirj commented 1 year ago

Since we're using Spoonacular, we need to be careful about users spamming requests and using all of our quota (free student plan has 5000 requests/day).

We plan to accomplish this by storing the number of requests that have been made to Spoonacular so far each day (in MongoDB) and resetting this value daily using a JS callback. One thing we should consider is per-user rate limiting, since we don't want to penalize all users if one user makes a huge amount of requests, but this can be something we consider later if needed.

mplekunov commented 1 year ago

implemented on the branch add-client-server-interface-for-recipeAPI

mplekunov commented 1 year ago

I accomplished it differently though, you can look at the the code on that branch, specifically SpoonacularAPIUtils folder. Essentially, this requirement is related to all API classes that use SpoonacularAPI. As such, it makes sense to create a base class with all similar functionalities that all API classes should have and then extend API classes related to SpoonacularAPI with that base class.

nashirj commented 1 year ago

Sounds good, when you make a PR, please link this issue