I've implemented some rate limiting in my firestore rules (using duration), and have been experimenting with rate limiting using this package's hooks on the client side. The function below compares the current time, against the last time a post was written to the db (represented in a field in a document). I consider my firestore rules as my backup rate limiter.
What are y'all doing to solve rate limiting on the client or with firestore rules?
sync: {
insertHook: function(updateStore, doc, store) {
const x = dayjs(); // current time
const y = dayjs.unix(store.getters["userData/lastPostTime"].seconds); // Unix to Local Time (yes, VEF could do this for me)
const duration = x.diff(y, "second", true);
duration > 10 // seconds
? updateStore(doc)
: alert("Your doing that too much.");
},
},
I've implemented some rate limiting in my firestore rules (using duration), and have been experimenting with rate limiting using this package's hooks on the client side. The function below compares the current time, against the last time a post was written to the db (represented in a field in a document). I consider my firestore rules as my backup rate limiter.
What are y'all doing to solve rate limiting on the client or with firestore rules?