Welcome to the repository for the article "Supercharge Your API with Type-Safe Validation using TSOA and Zod Decorators", published on Medium. This repo demonstrates how to integrate TSOA and Zod for building robust, type-safe REST APIs in Node.js with runtime validation.
In this project, you'll learn how to:
- Use TSOA for building type-safe REST APIs with TypeScript decorators.
- Integrate Zod for runtime data validation of API inputs.
- Create reusable decorators to simplify validation across multiple endpoints.
Before you begin, make sure you have the following installed:
- Node.js (v20.x or later)
- TypeScript (v5.x or later)
-
Clone the repository:
git clone https://github.com/pmullot/tsoa-zod-decorators.git cd tsoa-zod-decorators```
-
Install the dependencies:
npm install
-
Generate routes, specs and compile:
npm run build
- Run the project with:
npm start
- go to http://localhost:8000/api-docs and try it!!
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). For more details, please see the LICENSE file.
Happy coding!