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

[v3 checks] Remove references of returning simple objects from endpoints #4296

Closed
bluwy opened this issue Aug 21, 2023 · 5 comments
Closed
Assignees
Labels
improve documentation Enhance existing documentation (e.g. add an example, improve description) v3.0

Comments

@bluwy
Copy link
Member

bluwy commented Aug 21, 2023

📚 Subject area/topic

Endpoints

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/core-concepts/endpoints/

I don't see any other pages that needs updating, but could worth checking if I miss something.

📋 General description or bullet points (if proposing new content)

Endpoints should return with a Response instead of a simple object in Astro 3.0.

Note: While the migration guide has the ResponseWithEncoding API to ease the change, I don't think we want to recommend it as most setup can use Response with a little refactoring. For example, an image can be served like this too:

export async function get({ params, request }) {
  const response = await fetch("https://docs.astro.build/assets/full-logo-light.png");
  return new Response(await response.arrayBuffer());
}

So the docs should not use ResponseWithEncoding if possible.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

N/A. Original core PR: withastro/astro#8132

@bluwy bluwy added improve documentation Enhance existing documentation (e.g. add an example, improve description) v3.0 labels Aug 21, 2023
@fflaten
Copy link
Contributor

fflaten commented Aug 22, 2023

I don't see any other pages that needs updating, but could worth checking if I miss something.

RSS should also be updated with Response. New users are more likely to hit that than custom endpoints. 🙂

@bluwy
Copy link
Member Author

bluwy commented Aug 23, 2023

Wow thanks for flagging that. I miss that part for sure, I'll see if we can make that return a Response or simply a string instead.

@ElianCodes
Copy link
Member

@bluwy
Copy link
Member Author

bluwy commented Aug 25, 2023

Thanks @ElianCodes left a comment mostly about formatting, but I think you caught the rest of the changes!

@ElianCodes
Copy link
Member

Awesome! In that case I'm closing this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve documentation Enhance existing documentation (e.g. add an example, improve description) v3.0
Projects
None yet
Development

No branches or pull requests

3 participants