Skip to content

Commit

Permalink
Add Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
timoclsn committed Nov 8, 2023
1 parent d5adb74 commit aec4680
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/resources/lib/serverActions/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const createActionClient = <Context>(createClientOpts?: {
...inputArgs
) => {
const [input] = inputArgs;

try {
// Validate input if schema is provided
let parsedInput = input;
if (actionBuilderOpts.input) {
const result = actionBuilderOpts.input.safeParse(input);
Expand All @@ -36,8 +38,10 @@ export const createActionClient = <Context>(createClientOpts?: {
parsedInput = result.data;
}

// Run middleware if provided and get context
const ctx = (await createClientOpts?.middleware?.()) ?? ({} as Context);

// Call action
const response = await actionBuilderOpts.action({
input: parsedInput,
ctx,
Expand Down

1 comment on commit aec4680

@vercel
Copy link

@vercel vercel bot commented on aec4680 Nov 8, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.