Skip to content

Commit

Permalink
chore(website): remove null ctx from examples
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEdoRan committed Aug 24, 2024
1 parent ccacfe0 commit 0b641ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion website/docs/safe-action-client/extend-a-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getUserIdFromSessionId } from "./db";
// This is our base client.
// Here we define a middleware that logs the result of the action execution.
export const actionClient = createSafeActionClient().use(async ({ next }) => {
const result = await next({ ctx: null });
const result = await next();
console.log("LOGGING MIDDLEWARE: result ->", result);
return result;
});
Expand Down
7 changes: 6 additions & 1 deletion website/docs/safe-action-client/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ const actionClient = createSafeActionClient({
}).use(async ({ next, clientInput, metadata }) => {
console.log("LOGGING MIDDLEWARE");

const startTime = performance.now();

// Here we await the action execution.
const result = await next({ ctx: null });
const result = await next();

const endTime = performance.now();

console.log("Result ->", result);
console.log("Client input ->", clientInput);
console.log("Metadata ->", metadata);
console.log("Action execution took", endTime - startTime, "ms");

// And then return the result of the awaited action.
return result;
Expand Down

0 comments on commit 0b641ac

Please sign in to comment.