Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
throttle messages to no more than one every 5,000 milliseconds, see
type SharedWithInviteRequest {
createdDate: RateLimiting
// in order to write a message, I must first make an entry in users/${uid}/rate_limiting/{feature} is Number
// additionally, that message must be within 500ms of now, which means I can't
// just re-use the same one over and over, thus, we've effectively required messages
// to be 5 seconds apart
type RateLimiting extends Number {
validate() { this >= now - 500 && this === root['users'][auth.uid]['rate_limiting']['xyz'] }
path /users/{$urlUserId} {
// the new value must be at least 5000 milliseconds after the last (no more than one message every five seconds)
// the new value must be before now (it will be since `now` is when it reaches the server unless I try to cheat)
/rate_limiting/{$throttling} is Number {
read() { isOwner($urlUserId) }
write() { isOwner($urlUserId) }
validate() { $throttling.test(/^(xyz)$/) && this === now && (prior(this) == null || this > prior(this)+5000) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.