How do you guys structure your application when using zod? #1663
Replies: 4 comments 2 replies
|
My approach to folder structures is that it's based entirely on the goals/needs of the project/team. So I don't have a structure that I use everywhere. I'm guessing this doesn't help that much, but I wanted to answer your question so you didn't feel ignored. Sorry that I couldn't be of more help. If you have a more specific question, I could probably give a better answer. |
|
Things are always changing but right now my implementation in is to put everything in a types folder then define my exported schemas and exported types. After trying out a organized folder structure I found myself wishing I had put everything together into one file. I currently have a mono repo so this helps a lot as I just import my types to both the back end and front end from the single file. |
|
My practice is to place schemas inside /lib/schema/index.ts, and I believe this is an appropriate approach. While it is a matter of personal preference, logically speaking, it makes sense to store them in the lib or utils directory, as these directories are meant for libraries or utilities used throughout the project. I hope this clarifies my reasoning. |
Uh oh!
There was an error while loading. Please reload this page.
Just tried out zod and I love it. I would like to implement it across my React application.
An example of component folder in my app looks like:
So each component has a
components,helpers,typesetc folders.Do you guys do something simialr and create a
schemaor azodfolder? And just export the entire schema from there, allowing you to use it elsewhere? Or do something different, like store them all at a global level?Looking to see how others implement
zodinto their application in a clean way, as most tutorials just declare their schemas in the file.All reactions