support additional generic for typing incoming body & query
See original GitHub issuewould support something like this:
export default defineEventHandler<{ result: string }, { foo: string }>(async event => {
const { foo } = await useBody(event)
return {
result: foo
}
})
const result = await $fetch('/api/test', {
body: {
// auto-completing body, requiring
}
})
Follow-up tasks
- add support for typing query/body in Nitro generated types & ohmyfetch (via options)
possibly could also consider params?
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Typed Express Request and Response with ... - In Plain English
Request .body & query; A small security note on incoming requests ... this new interface it's possible to use generics to type the...
Read more >Model Binding | FastEndpoints
Query string parameters from the incoming request are bound automatically to the request DTO properties. See here for the types of properties supported...
Read more >How to cast req.query parameters in Express using Typescript
You could define the types that you will expect on the ReqBody , ReqQuery and the other generics of Request type.
Read more >Type-safe API mocking with Mock Service Worker and ...
Response body type. Request parameters. Let's take a look at the UPDATE /post/:postId request that utilizes all three said generics:.
Read more >Accepting Raw Request Body Content in ASP.NET Core API ...
NET Core has a clean and more generic way to handle custom formatting ... body and perform your own deserialization on the inbound...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just released h3-typebox (source) 🚀
Feedbacks are welcome !
This issue is still open for a built-in validation. Conventionally, by using the integration name in
h3-[integration]
we can support other possible validators from community.