Skip to content
Discussion options

You must be logged in to vote

Hello @noahdamiani ,

I don't understand the use-case.
What are you trying to achieve exactly?

Handlers of the both Middleware and Endpoint do not receive the schema — they receive the parsed and validated input data.

However, it's easy for the handler to be aware of the schema — just declare it in a const in outer scope.

const mySchema = z.object({ /* ... */ });

const myMiddleware = createMiddleware({
  input: mySchema,
  middleware: async () => {
    return doYourStuff( mySchema )
  }
})

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@noahdamiani
Comment options

@RobinTail
Comment options

Answer selected by RobinTail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants