Skip to content

feat: Support Content Types other than JSON (FormData, File, Blob, Uint8Array) - #5613

Merged
KATT merged 74 commits into
nextfrom
poc-content-types
Apr 20, 2024
Merged

KATT merged 74 commits into
nextfrom
poc-content-types

Conversation

@Nick-Lucas

@Nick-Lucas Nick-Lucas commented Apr 7, 2024 •

Copy link
Copy Markdown
Contributor

Prototyping a simplified Content Types system with support for two families of types:

  • FormData
  • File, Blob, Uint8Array, data (octet-streams)

🎯 Changes

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

βœ… 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.

@vercel

vercel Bot commented Apr 8, 2024 •

Copy link
Copy Markdown

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 20, 2024 9:08am
og-image βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 20, 2024 9:08am
www βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 20, 2024 9:08am

* When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure
*/
export function parseOctetInput<
TInput extends File | Blob | Uint8Array,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
TInput extends File | Blob | Uint8Array,
TInput extends Blob | Uint8Array,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm this one's trickier, thing is while the TS type is on the backend, it propagates to the frontend's types and is essential if you want to send a file.

Should we do a little ponyfill somehow? Not sure how to approach that

Comment on lines +35 to +36
type CreateContextCallback,
type WrapCreateContext,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do these need to be exported?

if so, smurf them πŸ‘€

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes they do, I was getting the usual portability error on the frontend

juliusmarminge
juliusmarminge previously approved these changes Apr 19, 2024
juliusmarminge
juliusmarminge previously approved these changes Apr 19, 2024
@Nick-Lucas Nick-Lucas mentioned this pull request Apr 19, 2024
1 task done
KATT
KATT previously approved these changes Apr 19, 2024
@github-actions

Copy link
Copy Markdown
Contributor

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.

This branch was successfully deployed

5 active deployments
Preview – www β€” b72a0501 Deployed Apr 20, 2024 by vercel[bot]
Preview – trpc-next-app-dir β€” b72a0501 Deployed Apr 20, 2024 by vercel[bot]
Preview – next-prisma-starter β€” b72a0501 Deployed Apr 20, 2024 by vercel[bot]
Preview – todomvc β€” b72a0501 Deployed Apr 20, 2024 by vercel[bot]
Preview – og-image β€” b72a0501 Deployed Apr 20, 2024 by vercel[bot]
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.

3 participants