Skip to content

Commit

Permalink
docs(request): getValidated* utils are async (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrentz authored Dec 3, 2024
1 parent 500e672 commit 2aac4f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions docs/2.utils/1.request.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
});
});
Expand All @@ -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(),
Expand All @@ -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";
});
});
Expand All @@ -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(),
Expand Down
16 changes: 8 additions & 8 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 2aac4f9

Please sign in to comment.