Request Input In Middleware #149
Unanswered
Lermatroid
asked this question in
Q&A
Replies: 1 comment
-
This would be the easy way: import { z } from "zod";
import { actionClient } from "@/lib/safe-action";
const documentSchema = z.object({
documentId: z.string(),
});
const testAction = actionClient
.use(async ({ next, ctx, clientInput }) => {
const parsedInput = clientInput as z.infer<typeof documentSchema>;
// Access document id
const { documentId } = parsedInput;
return next({ ctx });
})
.schema(documentSchema)
.action(async () => {}); You could export |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I wanted to know if there is a way request input inside of a middleware on any actions that use that middleware. I am writing a middleware that performs mutations on documents, and want to request a document ID every time and validate its existence / that the user owns it.
Is this something I can implement in middleware? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions