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.0.0-beta.1 to 2.0.0

12

CHANGELOG.md
# koa-zod-router
## 2.0.0
### Major Changes
- 62874b1: Improved Router context by extending Koa.Context (Potential breaking change)
Previously, koa-zod-router's context did not extend Koa.Context due to potential conflicts with other third-party libraries that may have overridden Koa.Context globally. However, after addressing all internal issues, we have now enhanced Router context by extending Koa.Context for better interoperability with other Koa-based libraries.
While we have conducted thorough testing, there is still a possibility that this change may affect some third-party libraries. Hence, we are flagging this as a potential breaking change.
Added feature: validationErrorHandler option for router-wide error handling
## 1.2.1

@@ -4,0 +16,0 @@

2

package.json
{
"name": "koa-zod-router",
"version": "2.0.0-beta.1",
"version": "2.0.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -267,4 +267,29 @@ # ⚡ koa-zod-router ⚡

### Custom Validation Error Handling
## Custom Validation Error Handling
`koa-zod-router` allows users to implement router-wide error handling or route specific error handling.
### Router-wide error handling
By passing a function `validationErrorHandler` into `zodRouter` options you can execute an error handler that occurs immediately after the validation-middleware does it's thing.
```js
import { ValidationErrorHandler } from 'koa-zod-router';
const validationErrorHandler: ValidationErrorHandler = async (ctx, next) => {
if (ctx.invalid.error) {
ctx.status = 400;
ctx.body = 'hello';
} else {
await next();
}
return;
};
const router = zodRouter({
zodRouter: { exposeResponseErrors: true, validationErrorHandler },
});
```
### Route specific error handling
By enabling `continueOnError` you can bypass the default error handling done by the router's validation middleware and handle the errors the way you see fit.

@@ -271,0 +296,0 @@

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