Skip to content
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

feat: support formdata in fetch adapter #5649

Closed
wants to merge 12 commits into from

Conversation

juliusmarminge
Copy link
Member

@juliusmarminge juliusmarminge commented Apr 20, 2024

Ref #5648

🎯 Changes

What changes are made in this PR? Is it a feature or a bug fix?

  • adds FormData support in fetch adapter
  • adds octet support in fetch adapter
  • makes Request generic since most frameworks has their own extended type that sets some extra properties on top of the standard

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.
    • had to disable it though since miniflare doesnt seem to work

Copy link

vercel bot commented Apr 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview Apr 21, 2024 0:29am
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 21, 2024 0:29am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 21, 2024 0:29am

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @juliusmarminge and the rest of your teammates on Graphite Graphite

Copy link

github-actions bot commented Apr 20, 2024

Diagnostics Comparison

Numbers

Metric PR next
Files 795 795 (➖ 0)
Lines of Library 40,640 40,640 (➖ 0)
Lines of Definitions 118,086 118,098 (🔽🟢 -12)
Lines of TypeScript 4,967 4,967 (➖ 0)
Lines of JavaScript 0 0 (➖ 0)
Lines of JSON 0 0 (➖ 0)
Lines of Other 0 0 (➖ 0)
Identifiers 174,931 174,966 (🔽🟢 -35)
Symbols 109,020 109,035 (🔽🟢 -15)
Types 89 89 (➖ 0)
Instantiations 0 0 (➖ 0)
Memory used 176,178 175,890 (🔺 288)
Assignability cache size 0 0 (➖ 0)
Identity cache size 0 0 (➖ 0)
Subtype cache size 0 0 (➖ 0)
Strict subtype cache size 0 0 (➖ 0)

Timings and averages

Metric PR next
max (s) 4.405 4.406 (➖ -0)
min (s) 4.405 4.406 (➖ -0)
avg (s) 4.405 4.406 (➖ -0)
median (s) 4.405 4.406 (➖ -0)
length 1 1 (➖ 0)
unstable timings

Unstable

Timings are not reliable in here

Metric PR next
I/O Read time 0.04 0.04 (➖ 0)
Parse time 0.85 0.74 (🔺 0.11)
ResolveTypeReference time 0.03 0.03 (➖ 0)
ResolveModule time 0.11 0.11 (➖ 0)
ResolveLibrary time 0.02 0.02 (➖ 0)
Program time 1.19 1.07 (🔺 0.12)
Bind time 0.42 0.43 (🔽🟢 -0.01)
Total time 1.61 1.51 (🔺 0.1)

Comment on lines 51 to 54
const form = new FormData();
form.append('foo', 'bar');
const postFormData = await proxy.formData.mutate(form);
console.log('formData reponse', postFormData);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test run:

CleanShot 2024-04-20 at 12 28 26

.input(z.instanceof(FormData))
.mutation(({ input }) => {
const object = {} as Record<string, unknown>;
input.forEach((value, key) => (object[key] = value));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do some Object.fromEntries-thing here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a copy-pasta from Nicks vanilla router

@@ -244,6 +256,26 @@ describe('with default server', () => {

await client.foo.query();
});

// Miniflare seems broken. Working test in examples/bun
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on this comment a bit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failed when it shouldn't

@KATT KATT closed this May 1, 2024
Copy link

github-actions bot commented May 3, 2024

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants