-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Remove support for simple objects in endpoints #9181
Conversation
🦋 Changeset detectedLatest commit: a6ec4d8 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
export async function GET({ params, request }) { | ||
const buffer = readFileSync(new URL('../../astro.png', import.meta.url)); | ||
return { | ||
body: buffer.toString('hex'), | ||
encoding: 'hex', | ||
}; | ||
export async function GET() { | ||
const buffer = await readFile(new URL('../../astro.png', import.meta.url)); | ||
return new Response(buffer.buffer); |
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.
TIL readFile with promises return a correctly encoded buffer compared to the sync version. I'm not sure why.
Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com>
Thanks for the approval. Since this change is slightly big and probably worth a docs pass, I'll hold off merging for now. |
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.
wait, so we didn't need response with encoding this whole time?
Yeah I found out over time that it's mostly to help simplify migration, most usecases can convert to |
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.
Changeset is very nice! One tiny suggestion, but otherwise very helpful!
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
Also removes
ResponseWithEncoding
and renames types for middlewares.A good chunk of the changes involved updating tests to not use the deprecated form.
Testing
Existing tests should pass.
Docs
Added to migration tracker