koa-zod-router
Advanced tools
Comparing version 2.2.1-beta.0 to 2.3.0
# koa-zod-router | ||
## 2.3.0 | ||
### Minor Changes | ||
- d02006b: Adds schema types to ctx.invalid | ||
## 2.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -9,8 +9,8 @@ import KoaRouter, { LayerOptions, RouterOptions } from '@koa/router'; | ||
type Method = 'acl' | 'bind' | 'checkout' | 'connect' | 'copy' | 'delete' | 'get' | 'head' | 'link' | 'lock' | 'm-search' | 'merge' | 'mkactivity' | 'mkcalendar' | 'mkcol' | 'move' | 'notify' | 'options' | 'patch' | 'post' | 'propfind' | 'proppatch' | 'purge' | 'put' | 'rebind' | 'report' | 'search' | 'source' | 'subscribe' | 'trace' | 'unbind' | 'unlink' | 'unlock' | 'unsubscribe'; | ||
interface ZodRouterInvalid { | ||
body?: ZodError; | ||
headers?: ZodError; | ||
params?: ZodError; | ||
query?: ZodError; | ||
files?: ZodError; | ||
interface ZodRouterInvalid<Headers, Params, Query, Body, Files> { | ||
body?: ZodError<Body>; | ||
headers?: ZodError<Headers>; | ||
params?: ZodError<Params>; | ||
query?: ZodError<Query>; | ||
files?: ZodError<Files>; | ||
error?: boolean; | ||
@@ -30,3 +30,3 @@ } | ||
} & Request; | ||
invalid: ZodRouterInvalid; | ||
invalid: ZodRouterInvalid<Headers, Params, Query, Body, Files>; | ||
} | ||
@@ -33,0 +33,0 @@ type ValidationOptions<Headers, Params, Query, Body, Files, Response> = { |
@@ -221,8 +221,11 @@ "use strict"; | ||
]); | ||
const inputErrors = validated.reduce((acc, curr) => { | ||
if (assertZodValidationError(curr)) { | ||
acc[curr.requestParameter] = curr.error; | ||
} | ||
return acc; | ||
}, {}); | ||
const inputErrors = validated.reduce( | ||
(acc, curr) => { | ||
if (assertZodValidationError(curr)) { | ||
acc[curr.requestParameter] = curr.error; | ||
} | ||
return acc; | ||
}, | ||
{ error: false } | ||
); | ||
if (inputErrors.body || inputErrors.files || inputErrors.headers || inputErrors.params || inputErrors.query) { | ||
@@ -256,3 +259,3 @@ if (validation?.continueOnError || opts?.validationErrorHandler) { | ||
} | ||
if (output.error instanceof import_zod2.ZodError) { | ||
if (assertZodValidationError(output)) { | ||
if (opts?.exposeResponseErrors) { | ||
@@ -259,0 +262,0 @@ ctx.status = 500; |
{ | ||
"name": "koa-zod-router", | ||
"version": "2.2.1-beta.0", | ||
"version": "2.3.0", | ||
"description": "", | ||
@@ -38,2 +38,5 @@ "main": "dist/index.js", | ||
"@koa/router": "^12.0.1", | ||
"@types/formidable": "^2.0.6", | ||
"@types/koa-bodyparser": "^4.3.11", | ||
"@types/koa__router": "^12.0.2", | ||
"formidable": "^2.1.2", | ||
@@ -44,7 +47,4 @@ "koa-bodyparser": "^4.4.1", | ||
"devDependencies": { | ||
"@types/formidable": "^2.0.6", | ||
"@types/koa-bodyparser": "^4.3.11", | ||
"@types/koa__router": "^12.0.2", | ||
"@changesets/cli": "^2.26.2", | ||
"@types/koa": "^2.15.0", | ||
"@types/koa": "^2.13.10", | ||
"@types/node": "^18.18.6", | ||
@@ -60,3 +60,3 @@ "@types/supertest": "^2.0.15", | ||
"husky": "^8.0.3", | ||
"koa": "^2.15.1", | ||
"koa": "^2.14.2", | ||
"mocha": "^10.2.0", | ||
@@ -73,3 +73,3 @@ "mocha-lcov-reporter": "^1.3.0", | ||
"peerDependencies": { | ||
"koa": ">=2.15.1 <3.x", | ||
"koa": ">=2.14.1 <3.x", | ||
"zod": ">=3.22.4 <4.x" | ||
@@ -76,0 +76,0 @@ }, |
Sorry, the diff of this file is not supported yet
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 v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
78197
22
1085
1
9
+ Added@types/formidable@^2.0.6
+ Added@types/koa__router@^12.0.2
+ Added@types/accepts@1.3.7(transitive)
+ Added@types/body-parser@1.19.5(transitive)
+ Added@types/connect@3.4.38(transitive)
+ Added@types/content-disposition@0.5.8(transitive)
+ Added@types/cookies@0.9.0(transitive)
+ Added@types/express@5.0.0(transitive)
+ Added@types/express-serve-static-core@5.0.2(transitive)
+ Added@types/formidable@2.0.6(transitive)
+ Added@types/http-assert@1.5.6(transitive)
+ Added@types/http-errors@2.0.4(transitive)
+ Added@types/keygrip@1.0.6(transitive)
+ Added@types/koa@2.15.0(transitive)
+ Added@types/koa-bodyparser@4.3.12(transitive)
+ Added@types/koa-compose@3.2.8(transitive)
+ Added@types/koa__router@12.0.4(transitive)
+ Added@types/mime@1.3.5(transitive)
+ Added@types/node@22.10.2(transitive)
+ Added@types/qs@6.9.17(transitive)
+ Added@types/range-parser@1.2.7(transitive)
+ Added@types/send@0.17.4(transitive)
+ Added@types/serve-static@1.15.7(transitive)
+ Addedundici-types@6.20.0(transitive)