diff --git a/decorators.ts b/decorators.ts index dd9dcd2..7a1d341 100644 --- a/decorators.ts +++ b/decorators.ts @@ -1,6 +1,7 @@ -import { NotValidBodyException, createParamDecorator, OptionsResolver, type HttpContext } from './deps.ts'; +import { NotValidBodyException, createParamDecorator, OptionsResolver, type ExecutionContext } from './deps.ts'; +import { z } from "https://deno.land/x/zod/mod.ts"; -export const ZodBody = (zodSchema: any, prop?: string) => createParamDecorator(async (context: HttpContext, opts?: OptionsResolver) => { +export const ZodBody = (zodSchema: z.ZodObject, prop?: string) => createParamDecorator(async (context: ExecutionContext, opts?: OptionsResolver) => { if (!opts) { throw { status: 500, @@ -27,7 +28,7 @@ export const ZodBody = (zodSchema: any, prop?: string) => createParamDecorator(a })(); -export const ZodQuery = (zodSchema: any) => createParamDecorator(async (context: HttpContext, opts?: OptionsResolver) => { +export const ZodQuery = (zodSchema: z.ZodObject) => createParamDecorator(async (context: ExecutionContext, opts?: OptionsResolver) => { const param = context.req.query() const operation = zodSchema.safeParse(param); if (!operation.success) { diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..2322c71 --- /dev/null +++ b/deno.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "jsx": "react-jsx", + "jsxImportSource": "preact" + } +} diff --git a/deps.ts b/deps.ts index 9852f25..ea790c5 100644 --- a/deps.ts +++ b/deps.ts @@ -1,4 +1,4 @@ -export { DanetApplication, type HttpContext } from 'https://deno.land/x/danet/mod.ts'; +export { DanetApplication, type ExecutionContext } from 'https://deno.land/x/danet/mod.ts'; export { MetadataHelper } from 'https://deno.land/x/danet/src/metadata/mod.ts'; export { NotValidBodyException } from 'https://deno.land/x/danet/src/exception/http/exceptions.ts'; export { createParamDecorator, type OptionsResolver } from 'https://deno.land/x/danet/src/router/controller/params/decorators.ts';