Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-zod-router

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-zod-router - npm Package Compare versions

Comparing version 2.2.1-beta.0 to 2.3.0

6

CHANGELOG.md
# koa-zod-router
## 2.3.0
### Minor Changes
- d02006b: Adds schema types to ctx.invalid
## 2.2.0

@@ -4,0 +10,0 @@

14

dist/index.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc