koa-zod-router
Advanced tools
Comparing version 1.0.3 to 1.0.4-beta.0
import * as koa from 'koa'; | ||
import { Middleware, DefaultState } from 'koa'; | ||
import KoaRouter, { RouterOptions, LayerOptions } from '@koa/router'; | ||
import KoaRouter, { LayerOptions, RouterOptions } from '@koa/router'; | ||
import formidable from 'formidable'; | ||
@@ -42,2 +42,8 @@ import bodyParser from 'koa-bodyparser'; | ||
} & Spec<H, P, Q, B, F, R>; | ||
declare function RouterMethodFn<H, P, Q, B, F, R>(path: string, handler: ZodMiddleware<H, P, Q, B, F, R>, validationOptions?: ValidationOptions<H, P, Q, B, F, R>): KoaRouter; | ||
declare function RouterMethodFn<H, P, Q, B, F, R>(spec: Spec<H, P, Q, B, F, R>): KoaRouter; | ||
type RouterMethod = typeof RouterMethodFn; | ||
type RouterMethods = { | ||
[key in Method]: RouterMethod; | ||
}; | ||
type ZodRouter = ReturnType<typeof zodRouter>; | ||
@@ -220,2 +226,2 @@ interface RouterOpts { | ||
export { RouterOpts, ZodRouter, createRouteSpec, zodRouter as default, zFile }; | ||
export { Method, RegisterSpec, RouteSpec, RouterMethod, RouterMethods, RouterOpts, Spec, ValidationOptions, ZodContext, ZodMiddleware, ZodRouter, createRouteSpec, zodRouter as default, zFile, zodRouter }; |
@@ -31,3 +31,4 @@ "use strict"; | ||
default: () => src_default, | ||
zFile: () => zFile | ||
zFile: () => zFile, | ||
zodRouter: () => zod_router_default | ||
}); | ||
@@ -385,3 +386,4 @@ module.exports = __toCommonJS(src_exports); | ||
createRouteSpec, | ||
zFile | ||
zFile, | ||
zodRouter | ||
}); |
{ | ||
"name": "koa-zod-router", | ||
"version": "1.0.3", | ||
"version": "1.0.4-beta.0", | ||
"description": "", | ||
@@ -19,3 +19,4 @@ "main": "dist/index.js", | ||
"lint:turbo": "turbo run lint", | ||
"release": "pnpm build:turbo && npm publish" | ||
"release": "pnpm build:turbo && npm publish", | ||
"release:beta": "pnpm build:turbo && npm publish --tag beta" | ||
}, | ||
@@ -22,0 +23,0 @@ "author": { |
@@ -103,2 +103,14 @@ # ⚡ koa-zod-router ⚡ | ||
### Exposing validation errors to the client | ||
By default validation errors will respond with either a generic 400 or 500 error depending on whether the validation fails from the sent fields in the request, or if there is an issue in the response body. | ||
To enable ZodErrors being exposed to the client simply use the following config: | ||
```js | ||
const router = zodRouter({ | ||
zodRouter: { exposeRequestErrors: true, exposeResponseErrors: true }, | ||
}); | ||
``` | ||
### Type coercion | ||
@@ -181,6 +193,9 @@ | ||
Found a bug? Have a question or idea? | ||
Found a bug? | ||
Please let me know in [Issues section](https://github.com/JakeFenley/koa-zod-router/issues). | ||
Have a question or idea? | ||
Please let me know in [Discussions section](https://github.com/JakeFenley/koa-zod-router/discussions). | ||
Found a vulnerability or other security issue? | ||
Please refer to [Security policy](https://github.com/JakeFenley/koa-zod-router/blob/main/SECURITY.md). |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
47165
948
199
2