-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/dev-deps-d3e0efbd4f
- Loading branch information
Showing
11 changed files
with
210 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
**Please make sure to read the [Types](../types.md) page before continuing.** | ||
|
||
|
||
You can declare `headers` parameters in the `request` property of your endpoint schema. | ||
|
||
The validated data is available under `data.headers.<name>`. | ||
|
||
```ts hl_lines="10-12" | ||
import {OpenAPIRoute, Ip} from 'chanfana' | ||
import {z} from 'zod' | ||
import {Context} from 'hono' | ||
|
||
export class ToDoFetch extends OpenAPIRoute { | ||
schema = { | ||
tags: ['ToDo'], | ||
summary: 'Fetch a ToDo', | ||
request: { | ||
headers: z.object({ | ||
forwardedFor: Ip() | ||
}) | ||
} | ||
} | ||
|
||
async handle(c: Context) { | ||
const data = await this.getValidatedData<typeof this.schema>() | ||
|
||
// You get full type inference when accessing the data variable | ||
data.headers.forwardedFor | ||
|
||
// ... | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,12 @@ | |
"umd", | ||
"typed" | ||
], | ||
"author": "[email protected]", | ||
"author": "Gabriel Massadas <[email protected]> (https://github.com/g4brym)", | ||
"license": "MIT", | ||
"homepage": "https://chanfana.pages.dev", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/cloudflare/chanfana.git" | ||
"url": "https://github.com/cloudflare/chanfana.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cloudflare/chanfana/issues" | ||
|
Oops, something went wrong.