hcp-uw / syntext

website for practicing your typing
5 stars 0 forks source link

User able to overwhelm API with requests from front end #44

Closed elimelt closed 1 year ago

elimelt commented 1 year ago

Need to find a way to limit the speed with which the user can make requests to our backend, as it seems that right now if you spam new snippet then the responses start to become delayed.

A potential fix is to pre-load all of the matching snippets every time the user changes their snippet settings. This way, a request is only made when changing the settings and not by pushing the new snippet button.

elimelt commented 1 year ago

Implemented the above "potential fix".

Snippet service now returns array of resulting snippets objects (including metadata: id, length, type) and SnippetOptions/GameOptions cycles between all results.

With my current implementation there is no randomness. ie the snippets will always occur in the same order. We can later fix this by introducing a random starting index of the array, and a random value to increment the current snippet by.

elimelt commented 1 year ago

closing this issue since the problem is resolved!