Open
Conversation
Contributor
|
View Vercel preview at instant-www-js-request-time-jsv.vercel.app. |
nezaj
approved these changes
Feb 6, 2026
Contributor
nezaj
left a comment
There was a problem hiding this comment.
Woohoo! Did we want to include docs with this or put that in a separate PR?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Easier to review with whitespace turned off https://github.com/instantdb/instant/pull/2263/changes?w=1
Adds
request.time,request.origin, andrequest.ipto the rules file.The
request.timeis a cel timestamp. In order to make it easier to use, I added a.getTimefunction to timestamps that will return the value in milliseconds since the epoch (same asDate.getTimein javascript).I also overrode the default
timestampfunction to accept anything that we accept as a date instead of just rfc 3339 strings.The sandbox allows you to override ip and origin for testing.
To set the ip and origin, I put them in a
*request-info*dynamic binding. It's set in http middleware to catch any admin requests, and then it's set in handle-receive from the socket-ip and the socket-origin.I upgraded cel and added the math extensions so that you could reasonably write rules protecting the updatedAt field. It looks like:
Subtracting timestamps creates a duration, which you can call getMinutes on, then math.abs gets you within either side of the 1 minute of leeway.