{"repo":"JakeFenley/koa-zod-router","free":true,"listed":false,"github":"https://github.com/JakeFenley/koa-zod-router","clone":"git clone https://github.com/JakeFenley/koa-zod-router.git","description":"Build typesafe routes for Koa with ease. Utilizes Typescript, Zod, and Koa-Router to provide an easy solution to I/O validation and type inference.","language":"TypeScript","stars":66,"topics":["api","endpoint","http","koa","koa-router","middleware","nodejs","router","schema","schema-validation"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"This library is no longer maintained, and is not accepting pull requests. ⚡ koa-zod-router ⚡ Inspired by koa-joi-router, this package aims to provide a similar feature-set while leveraging Zod and Typescript to create typesafe routes and middlewares with built in I/O validation. [zod]: https://github.com/colinhacks/zod [coercion]: https://zod.dev/?id=coercion-for-primitives [koa-bodyparser]: https://github.com/koajs/bodyparser [formidable]: https://github.com/node-formidable/formidable [@koa/router]: https://github.com/koajs/router 🔥 Features: - Input/output validation and typesafety using [zod][] - Body parsing using [koa-bodyparser][] - Multipart parsing using [formidable][] - Wraps [@koa/router][], providing the same API but with typesafety and validation. - Custom validation error handling support - RegExp path support - CJS and ESM support 🚀 Install 🚦 Quickstart index.ts: Importing/Exporting routes Most likely you'll want to seperate your routes into seperate files, and register them somewhere in your app's initialization phase. To do this you can use the helper function createRouteSpec and specify the route's properties. get-user.ts: index.ts: Adding state to routes zodRouter accepts a type parameter for adding types to ctx.state , as well as providing a helper function used creating routes and middlewares with state types. route-state.ts: auth-middleware.ts: get-user.ts: index.ts: Exposing validation errors to the client By default validation errors will respond wit","default_branch":null,"files":null,"tree":[],"storefront":"/r/JakeFenley","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/JakeFenley/koa-zod-router/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}