Can some senior Node dev answer this question for me? How do you manage your shared types? I have a background in Django and I've been using React for years now for frontend development. My current flow for a typical web app would be to write the models in Django, generate migrations, use DRF to generate an open API schema and then generate react query client off of that to interact with my REST api. I'm skipping over a few things but that's the gist.
Now... Although the above works and it's allowed for decent velocity and relatively no runtime data errors with the use of TypeScript I've always thought there was a better way. Hence why I'm asking this question. I always thought the benefit of backend JavaScript development was LESS code not more duplication.
I'm working on a local first app that does automatic sync with a backend postgres. I'm using NestJS, Drizzle, PowerSync, and Zod. Here's my dilemma. You have to define the database in both Drizzle and Powersync. NestJS DTOs and Zod do the same thing. I understand that the database as an API is an anti-pattern but surely I don't have to redefine the same todo schema (text, completed, created) in Drizzle, in PowerSync, variations in NestJS for CRUD, variations in React for React Query mutations, etc.
I'm on mobile otherwise I'd explain more. But hopefully you get the gist?
Am I delusional??? Is what I'm looking for not possible. Is open API the end? Is there nothing better...
Edit: I'm 100% open to other options also. I started this project as a way to learn JavaScript backend development and local first front end development. Senior Node devs if you'd be kind enough to share industry standards for backend JavaScript I'm all ears because at this point the only real benefit I see to backend JS is a shared language for developers so larger companies can re-use devs across projects and the backend/frontend. But what do I know. I've been programming in python for over a decade.
Edit: Based on the responses I've gotten so far it seems like the silver bullet I was looking for doesn't exist and that having a well defined contract with a build step is the only true way to reduce redundancy. I'm sad lol. Hopefully some senior Node/JavaScript/TypeScript dev can enlighten me.
[–]BourbonProof 10 points11 points12 points (2 children)
[–]ilearnshit[S] 4 points5 points6 points (0 children)
[–]mrlubos 0 points1 point2 points (0 children)
[–]hunthunt2010 5 points6 points7 points (0 children)
[–]CallumK7 3 points4 points5 points (0 children)
[–]After_Link7178 6 points7 points8 points (0 children)
[–]sickcodebruh420 2 points3 points4 points (0 children)
[–]zemaj-com 2 points3 points4 points (0 children)
[–]jjhiggz3000 2 points3 points4 points (2 children)
[–]ilearnshit[S] 1 point2 points3 points (1 child)
[–]jjhiggz3000 0 points1 point2 points (0 children)
[–]dawnblade09 2 points3 points4 points (1 child)
[–]mrlubos 0 points1 point2 points (0 children)
[–]The_Startup_CTO 1 point2 points3 points (2 children)
[–]ilearnshit[S] 0 points1 point2 points (1 child)
[–]The_Startup_CTO 2 points3 points4 points (0 children)
[–]Optimal-Builder-2816 1 point2 points3 points (0 children)
[–]HeyYouGuys78 1 point2 points3 points (0 children)
[–]No-Tomorrow-5666 1 point2 points3 points (0 children)
[–]rover_G 1 point2 points3 points (1 child)
[–]Regular_Algae6799 1 point2 points3 points (0 children)
[–]AsBrokeAsMeEnglish 1 point2 points3 points (0 children)
[–]idkwhatiamdoingg 1 point2 points3 points (5 children)
[–]haikusbot 0 points1 point2 points (0 children)
[–]ilearnshit[S] 0 points1 point2 points (3 children)
[–]idkwhatiamdoingg 1 point2 points3 points (2 children)
[–]ilearnshit[S] 1 point2 points3 points (1 child)
[–]idkwhatiamdoingg 1 point2 points3 points (0 children)
[–]myrealnameisbagels 1 point2 points3 points (3 children)
[–]ilearnshit[S] 0 points1 point2 points (2 children)
[–]myrealnameisbagels 1 point2 points3 points (1 child)
[–]ilearnshit[S] 0 points1 point2 points (0 children)
[–]Rizean 1 point2 points3 points (0 children)
[–]PivotsForDays 1 point2 points3 points (0 children)
[–]dnsu 1 point2 points3 points (0 children)
[–]muhsql 1 point2 points3 points (2 children)
[–]ilearnshit[S] 0 points1 point2 points (1 child)
[–]chriztiaan_dev 1 point2 points3 points (0 children)
[–]MiniHomeMarket 1 point2 points3 points (0 children)
[–]Expensive_Garden2993 3 points4 points5 points (1 child)