executeServerFn
Runs a server function definition: validation, middleware, then the handler.
Runs a server function definition: validation, middleware, then the handler. Used by the RPC endpoint and by direct calls, so both take the same path.
Import#
ts
import { executeServerFn } from "@shadow-js/dusk/server";
Signature#
ts
async function executeServerFn(
definition: ServerFnDefinition,
raw: unknown,
event: RequestEvent,
): Promise<unknown>
Parameters#
| Name | Description |
|---|---|
definition |
The function. |
raw |
The untrusted input. |
event |
The request event. |
Returns#
The handler's result.
Throws#
- ValidationError for input that fails the schema; whatever the middleware or handler throw.
Examples#
ts
const value = await executeServerFn(definition, { title: "x" }, event);