koa-zod-router
Advanced tools
Comparing version 0.9.14 to 1.0.0
# koa-zod-router | ||
## 0.9.14 | ||
## 1.0.0 | ||
### Patch Changes | ||
### Major Changes | ||
- 0735721: Preparing for v1 | ||
## 0.9.13 | ||
### Patch Changes | ||
- 629a712: Preparing for v1 | ||
## 0.9.12 | ||
### Patch Changes | ||
- ea18c77: Preparing for v1 | ||
- c8cabc0: Release v1 |
@@ -31,10 +31,13 @@ import * as koa from 'koa'; | ||
path: string; | ||
handlers: ZodMiddleware<H, P, Q, B, F, R>; | ||
handler: ZodMiddleware<H, P, Q, B, F, R>; | ||
pre?: ZodMiddleware<H, P, Q, B, F, R>; | ||
validate?: ValidationOptions<H, P, Q, B, F, R>; | ||
opts?: LayerOptions; | ||
}; | ||
type RegisterSpec<H, P, Q, B, F, R> = { | ||
method: Method | Method[]; | ||
opts?: LayerOptions; | ||
} & Spec<H, P, Q, B, F, R>; | ||
type RouteSpec<H, P, Q, B, F, R> = { | ||
method?: Method | Method[]; | ||
} & Spec<H, P, Q, B, F, R>; | ||
type ZodRouter = ReturnType<typeof zodRouter>; | ||
@@ -54,3 +57,3 @@ interface RouterOpts { | ||
readonly router: KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
readonly register: <H = unknown, P = unknown, Q = unknown, B = unknown, F = unknown, R = unknown>(spec: RegisterSpec<H, P, Q, B, F, R>) => KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
readonly register: <H, P, Q, B, F, R>(spec: RegisterSpec<H, P, Q, B, F, R> | RouteSpec<H, P, Q, B, F, R>) => KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
readonly all: { | ||
@@ -78,135 +81,135 @@ <T = {}, U = {}, B_1 = unknown>(name: string, path: string | RegExp, ...middleware: KoaRouter.Middleware<koa.DefaultState & T, koa.DefaultContext & U, B_1>[]): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
readonly acl: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly bind: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly checkout: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly connect: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly copy: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly delete: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly get: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly head: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly link: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly lock: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly "m-search": { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly merge: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly mkactivity: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly mkcalendar: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly mkcol: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly move: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly notify: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly options: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly patch: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly post: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly propfind: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly proppatch: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly purge: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly put: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly rebind: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly report: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly search: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly source: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly subscribe: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly trace: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly unbind: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly unlink: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly unlock: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
}; | ||
readonly unsubscribe: { | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handlers: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_1, P_1, Q_1, B_3, F_1, R_1>(path: string, handler: ZodMiddleware<H_1, P_1, Q_1, B_3, F_1, R_1>, validationOptions?: ValidationOptions<H_1, P_1, Q_1, B_3, F_1, R_1> | undefined): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
<H_2, P_2, Q_2, B_4, F_2, R_2>(spec: Spec<H_2, P_2, Q_2, B_4, F_2, R_2>): KoaRouter<koa.DefaultState, koa.DefaultContext>; | ||
@@ -217,3 +220,4 @@ }; | ||
declare const zFile: () => z.ZodUnion<[z.ZodType<formidable_PersistentFile, z.ZodTypeDef, formidable_PersistentFile>, z.ZodType<formidable_PersistentFile, z.ZodTypeDef, formidable_PersistentFile>]>; | ||
declare const createRouteSpec: <Headers = z.ZodType<any, z.ZodTypeDef, any>, Params = z.ZodType<any, z.ZodTypeDef, any>, Query = z.ZodType<any, z.ZodTypeDef, any>, Body = z.ZodType<any, z.ZodTypeDef, any>, Files = z.ZodType<any, z.ZodTypeDef, any>, Response = z.ZodType<any, z.ZodTypeDef, any>>(spec: RouteSpec<Headers, Params, Query, Body, Files, Response>) => RouteSpec<Headers, Params, Query, Body, Files, Response>; | ||
export { RouterOpts, ZodRouter, zodRouter as default, zFile }; | ||
export { RouterOpts, ZodRouter, createRouteSpec, zodRouter as default, zFile }; |
@@ -29,2 +29,3 @@ "use strict"; | ||
__export(src_exports, { | ||
createRouteSpec: () => createRouteSpec, | ||
default: () => src_default, | ||
@@ -92,2 +93,5 @@ zFile: () => zFile | ||
}; | ||
var createRouteSpec = (spec) => { | ||
return spec; | ||
}; | ||
var methods = [ | ||
@@ -309,2 +313,5 @@ "acl", | ||
function register(spec) { | ||
if (!spec.method) { | ||
throw new Error(`HTTP Method missing in spec ${spec.path}`); | ||
} | ||
const methodsParam = Array.isArray(spec.method) ? spec.method : [spec.method]; | ||
@@ -315,3 +322,3 @@ const name = spec.name ? spec.name : null; | ||
methodsParam, | ||
prepareMiddleware([spec.pre, validationMiddleware(spec.validate, opts?.zodRouter), spec.handlers]), | ||
prepareMiddleware([spec.pre, validationMiddleware(spec.validate, opts?.zodRouter), spec.handler]), | ||
{ name } | ||
@@ -322,8 +329,8 @@ ); | ||
const makeRouteMethods = () => methods.reduce((acc, method) => { | ||
acc[method] = (pathOrSpec, handlers, validationOptions) => { | ||
if (typeof pathOrSpec === "string" && assertHandlers(handlers)) { | ||
acc[method] = (pathOrSpec, handler, validationOptions) => { | ||
if (typeof pathOrSpec === "string" && assertHandlers(handler)) { | ||
register({ | ||
method, | ||
path: pathOrSpec, | ||
handlers, | ||
handler, | ||
validate: validationOptions | ||
@@ -373,3 +380,4 @@ }); | ||
0 && (module.exports = { | ||
createRouteSpec, | ||
zFile | ||
}); |
{ | ||
"name": "koa-zod-router", | ||
"version": "0.9.14", | ||
"version": "1.0.0", | ||
"description": "", | ||
@@ -12,6 +12,7 @@ "main": "dist/index.js", | ||
"build:turbo": "turbo run build", | ||
"example": "tsup examples/index.ts --watch", | ||
"example": "ts-node-dev examples/index.ts", | ||
"test": "mocha", | ||
"test:coverage": "nyc --reporter=text mocha", | ||
"test:turbo": "turbo run test:coverage", | ||
"test:ci": "nyc --reporter=lcov mocha", | ||
"test:turbo": "turbo run test:ci", | ||
"lint": "tsc && eslint \"src/**/*.ts\" --cache && prettier --check \"src/**/*.ts\"", | ||
@@ -43,2 +44,3 @@ "lint:turbo": "turbo run lint", | ||
"@typescript-eslint/parser": "^5.48.1", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^8.31.0", | ||
@@ -51,2 +53,3 @@ "eslint-config-prettier": "^8.5.0", | ||
"mocha": "^10.2.0", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"nyc": "^15.1.0", | ||
@@ -56,6 +59,6 @@ "prettier": "^2.8.2", | ||
"supertest": "^6.3.3", | ||
"ts-node": "^10.9.1", | ||
"ts-node-dev": "^2.0.0", | ||
"tsup": "^6.5.0", | ||
"turbo": "^1.7.0", | ||
"typescript": "^4.9.4" | ||
"typescript": "4.9.4" | ||
}, | ||
@@ -62,0 +65,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
43626
7
923
1
1
129
27