Use incoming event type in defineEventHandler
I want to run some custom logic using a function that takes the event from an event handler in a
.post.ts
file:
However, I want to use the type of the event in my function parameter so it doesn't error. What type do I use? When I hover over it, I get (parameter) event: H3Event<EventHandlerRequest>
but I can't seem to import that into my own code, and I'm also not sure if that's the type I want to be using. Is there an easier type that would work for this provided by Nuxt?
I basically just want to be able to get the event typed properly, passed into that function and then parsed with readValidatedBody
, etc.3 Replies
Ah, that works? Solid
I ask because I'm doing some stuff with Effect and trying to make things work:
I assume readValidatedBody doesn't have the result of the parsing as its return type but rather just a Promise? Right now, it's returning
Promise<T>
as decodeUnknownSync
and similar from Effect normally returns an Effect (in this case, it would be an Effect with either T or ParseError), I was curious
I can tell it works with Zod thoughSorry for hijacking this thread but did you manage to get Effect working with Nitro?
I find so little information on it so I have to take desperate measures, digging deep into discord messages. 😅