0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
astro/.changeset/six-icons-pump.md
Ben Holmes 29a8650375
Actions: restore api context param (#11112)
* feat: expose APIContext from the second handler param

* refactor: use second param from test

* chore: changeset

* edit: minor -> patch

* edit: apiContext -> context

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* refactor: apiContext -> context

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* refactor: apiContext -> context

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

---------

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
2024-05-22 08:06:58 -04:00

463 B

astro
patch

Deprecate the getApiContext() function. API Context can now be accessed from the second parameter to your Action handler():

// src/actions/index.ts
import {
  defineAction,
  z,
-  getApiContext,
} from 'astro:actions';

export const server = {
  login: defineAction({
    input: z.object({ id: z.string }),
+    handler(input, context) {
      const user = context.locals.auth(input.id);
      return user;
    }
  }),
}