-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Miniflare 3] Implement more of R2 and add tests #524
Conversation
|
0b6fa4a
to
c72c983
Compare
v4Code: number; | ||
object?: R2Object; | ||
|
||
constructor(status: number, message: string, v4Code: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status: number
should probably also be renamed to code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need this for R2 too
We made a similar change in Miniflare 2 recently
Validate incoming R2 requests from `workerd` with `zod`, increasing type safety. This removes some implicit `any`s from `JSON.parse`, and allows us to use `method` as a type-level union discriminator. Validation of types has also been removed from the `Validator` class, as we don't need to duplicate this. `workerd` will handle validating user input here.
Calling `head()` should return the full-range here
Note this is returning slightly different, but still correct, results to the real implementation. This is due a restriction of Miniflare's storage abstraction, see the comment in `list()` for more details. We're planning to replace this very soon though, so this shouldn't be a problem for long.
This restriction no longer seems to apply
ace5152
to
851c479
Compare
851c479
to
66cf2ec
Compare
This PR brings over some of the improvements from #470, and adds tests for the R2 implementation.
Specifically we now: (see commit descriptions for more details)
workerd
usingzod
to ensure type safety in the rest of the implementation (chunky)R2Bucket#delete()
Range
header inR2Bucket#get()
range
information fromR2Bucket#head()
R2Bucket#list()
startAfter
optionsha*
checksums inR2Bucket#put()
and return these fromR2Bucket#{get,head}
R2Bucket#put()
secondsGranularity
option inR2Conditional
sR2Object#version
a hex string to match the real implementationcustomMetadata
sizeBest reviewed commit-by-commit... 😅