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

Actions: Allow actions to be called on the server #11088

Merged
merged 15 commits into from
May 22, 2024

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented May 17, 2024

Changes

Allow actions to be called on the server.

---
// src/pages/blog/[postId].astro
import { actions } from 'astro:actions';

await actions.like({ postId: Astro.params.postId });
---
  • Ensure API context exists by wrapping the next() call from middleware with a context provider.
  • Add an SSR code path to the actions.mjs template. This imports the getAction() utility to retrieve the appropriate action by path name.

Testing

Add e2e test for calling the like action from astro frontmatter.

Docs

TODO: RFC update

Copy link

changeset-bot bot commented May 17, 2024

🦋 Changeset detected

Latest commit: 765dd72

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 May 17, 2024
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.

@bholmesdev bholmesdev changed the title wip: consume async local storage from defineAction() Actions: Allow actions to be called on the server May 17, 2024
@bholmesdev bholmesdev marked this pull request as ready for review May 17, 2024 22:04
.changeset/eighty-taxis-wait.md Outdated Show resolved Hide resolved
packages/astro/src/actions/runtime/middleware.ts Outdated Show resolved Hide resolved
@bholmesdev bholmesdev force-pushed the feat/server-action-calls branch 2 times, most recently from 6752b1a to a22138f Compare May 21, 2024 20:04
@bholmesdev bholmesdev merged commit 9566fa0 into main May 22, 2024
13 checks passed
@bholmesdev bholmesdev deleted the feat/server-action-calls branch May 22, 2024 16:46
@astrobot-houston astrobot-houston mentioned this pull request May 22, 2024
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.

None yet

3 participants