How do you guys structure your application when using zod? #1663
Replies: 4 comments 1 reply
-
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. |
Beta Was this translation helpful? Give feedback.
-
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.
|
Beta Was this translation helpful? Give feedback.
-
Try FSD (Feature-sliced design) |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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
,types
etc folders.Do you guys do something simialr and create a
schema
or azod
folder? 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
zod
into their application in a clean way, as most tutorials just declare their schemas in the file.Beta Was this translation helpful? Give feedback.
All reactions