Skip to content

Commit

Permalink
support for getValidatedRouterParams
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 20, 2023
1 parent 45741f8 commit 43f9c26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ H3 has a concept of composable utilities that accept `event` (from `eventHandler

- `getQuery(event)`
- `getValidatedQuery(event, validate)`
- `getRouterParams(event, opts)`
- `getRouterParam(event, name, opts)`
- `getValidatedRouterParams(event, validate)`
- `getRouterParams(event, { decode? })`
- `getRouterParam(event, name, { decode? })`
- `getValidatedRouterParams(event, validate, { decode? })`
- `getMethod(event, default?)`
- `isMethod(event, expected, allowHead?)`
- `assertMethod(event, expected, allowHead?)`
Expand Down
8 changes: 6 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ export function getValidatedRouterParams<
T,
Event extends H3Event = H3Event,
_T = InferEventInput<"routerParams", Event, T>,
>(event: Event, validate: ValidateFunction<_T>): Promise<_T> {
const routerParams = getRouterParams(event);
>(
event: Event,
validate: ValidateFunction<_T>,
opts: { decode?: boolean } = {},
): Promise<_T> {
const routerParams = getRouterParams(event, opts);

Check warning on line 54 in src/utils/request.ts

View check run for this annotation

Codecov / codecov/patch

src/utils/request.ts#L49-L54

Added lines #L49 - L54 were not covered by tests

return validateData(routerParams, validate);
}
Expand Down

0 comments on commit 43f9c26

Please sign in to comment.