Parsing Incoming Body with Effect and Nuxt: Handling Validation with zod and Schema

Quick question! I'm using Effect with Nuxt and trying to do some parsing of an incoming body:

const validateBody = <T>(schema: S.Schema<T>) => async (event: H3Event<EventHandlerRequest>) =>
  await readValidatedBody(event, S.decodeUnknownSync(schema))


readValidatedBody here returns Promise<T> while it should return (I think) an Effect<T, ParseError, never>. When using zod, I get this:

export default defineEventHandler(async (event) => {
  const objectSchema = z.object({});
  const body = await readValidatedBody(event, objectSchema.safeParse);
});

// const body: z.SafeParseSuccess<{}> | z.SafeParseError<{}>
Was this page helpful?