diff --git a/docs/2.utils/1.request.md b/docs/2.utils/1.request.md index fcb3e5e1..a7116ec4 100644 --- a/docs/2.utils/1.request.md +++ b/docs/2.utils/1.request.md @@ -138,8 +138,8 @@ You can use a simple function to validate the query object or a library like `zo **Example:** ```ts -app.use("/", (event) => { - const query = getValidatedQuery(event, (data) => { +app.use("/", async (event) => { + const query = await getValidatedQuery(event, (data) => { return "key" in data && typeof data.key === "string"; }); }); @@ -149,8 +149,8 @@ app.use("/", (event) => { ```ts import { z } from "zod"; -app.use("/", (event) => { - const query = getValidatedQuery( +app.use("/", async (event) => { + const query = await getValidatedQuery( event, z.object({ key: z.string(), @@ -170,8 +170,8 @@ You can use a simple function to validate the params object or a library like `z **Example:** ```ts -app.use("/", (event) => { - const params = getValidatedRouterParams(event, (data) => { +app.use("/", async (event) => { + const params = await getValidatedRouterParams(event, (data) => { return "key" in data && typeof data.key === "string"; }); }); @@ -181,8 +181,8 @@ app.use("/", (event) => { ```ts import { z } from "zod"; -app.use("/", (event) => { - const params = getValidatedRouterParams( +app.use("/", async (event) => { + const params = await getValidatedRouterParams( event, z.object({ key: z.string(), diff --git a/src/utils/request.ts b/src/utils/request.ts index d88ee29d..28007f5e 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -30,16 +30,16 @@ export function getQuery< * You can use a simple function to validate the query object or a library like `zod` to define a schema. * * @example - * app.use("/", (event) => { - * const query = getValidatedQuery(event, (data) => { + * app.use("/", async (event) => { + * const query = await getValidatedQuery(event, (data) => { * return "key" in data && typeof data.key === "string"; * }); * }); * @example * import { z } from "zod"; * - * app.use("/", (event) => { - * const query = getValidatedQuery( + * app.use("/", async (event) => { + * const query = await getValidatedQuery( * event, * z.object({ * key: z.string(), @@ -89,16 +89,16 @@ export function getRouterParams( * You can use a simple function to validate the params object or a library like `zod` to define a schema. * * @example - * app.use("/", (event) => { - * const params = getValidatedRouterParams(event, (data) => { + * app.use("/", async (event) => { + * const params = await getValidatedRouterParams(event, (data) => { * return "key" in data && typeof data.key === "string"; * }); * }); * @example * import { z } from "zod"; * - * app.use("/", (event) => { - * const params = getValidatedRouterParams( + * app.use("/", async (event) => { + * const params = await getValidatedRouterParams( * event, * z.object({ * key: z.string(),