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

Remove support for simple objects in endpoints #9181

Merged
merged 5 commits into from
Nov 27, 2023
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Nov 23, 2023

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

Copy link

changeset-bot bot commented Nov 23, 2023

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Nov 23, 2023
Comment on lines -3 to +5
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);
Copy link
Member Author

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>
@bluwy
Copy link
Member Author

bluwy commented Nov 24, 2023

Thanks for the approval. Since this change is slightly big and probably worth a docs pass, I'll hold off merging for now.

Copy link
Contributor

@matthewp matthewp left a 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?

@bluwy
Copy link
Member Author

bluwy commented Nov 27, 2023

Yeah I found out over time that it's mostly to help simplify migration, most usecases can convert to ArrayBuffer which Response can work with by itself.

Copy link
Member

@sarah11918 sarah11918 left a 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!

.changeset/clever-beds-notice.md Outdated Show resolved Hide resolved
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@matthewp matthewp merged commit cdabf6e into next Nov 27, 2023
14 checks passed
@matthewp matthewp deleted the deprecate-simple-objects branch November 27, 2023 17:51
@astrobot-houston astrobot-houston mentioned this pull request Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants