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

Add new fields to API route context #4986

Merged
merged 19 commits into from
Oct 12, 2022
Merged

Add new fields to API route context #4986

merged 19 commits into from
Oct 12, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Oct 5, 2022

Changes

Add new site, generator, url, clientAddress, props and redirect fields to API route context to match closer to Astro global API.

Support second optional parameter status for redirect() (both api and Astro global).

Also fixes: #4920

Refactored internally to share types between Astro global too.

Testing

Added a test in ssr-api-routes.

Docs

Docs: withastro/docs#1731

Added links in jsdoc referencing the new docs.

@changeset-bot
Copy link

changeset-bot bot commented Oct 5, 2022

🦋 Changeset detected

Latest commit: 4118636

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: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release labels Oct 5, 2022
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@matthewp
Copy link
Contributor

matthewp commented Oct 5, 2022

Should also have:

@bluwy bluwy marked this pull request as ready for review October 7, 2022 09:30
@bluwy bluwy requested a review from a team as a code owner October 7, 2022 09:30
@bluwy
Copy link
Member Author

bluwy commented Oct 7, 2022

This is ready for review 👍 Added the props and redirect fields, and updated the PR description.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Awesome work @bluwy! These are some really great quality-of-life improvements for API routes. Left some suggestions — I may have misunderstood some features so feel free to discard suggestions if they’re not correct.

packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
bluwy and others added 2 commits October 7, 2022 23:26
Co-authored-by: Chris Swithinbank <[email protected]>
Co-authored-by: Chris Swithinbank <[email protected]>
@bluwy
Copy link
Member Author

bluwy commented Oct 7, 2022

All great suggestions @delucis. Thanks!

@matthewp matthewp merged commit ebd364e into main Oct 12, 2022
@matthewp matthewp deleted the api-context-extra branch October 12, 2022 21:03
@astrobot-houston astrobot-houston mentioned this pull request Oct 12, 2022
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Jul 29, 2024
* See withastro/astro#4986 for `site`, `generator`, `url`, `clientAddress`, `props` and `redirect`
* See withastro/astro#6721 for `locals`
* See withastro/astro#9021 for `preferredLocale` and `preferredLocaleList`
* See withastro/astro#9101 for `currentLocale`
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Jul 29, 2024
* See withastro/astro#4986 for `site`, `generator`, `url`, `clientAddress`, `props` and `redirect`
* See withastro/astro#6721 for `locals`
* See withastro/astro#9021 for `preferredLocale` and `preferredLocaleList`
* See withastro/astro#9101 for `currentLocale`
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) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static APIRoutes can't receive props from getStaticPaths
3 participants