6 ms·
I love tRPC, it's by far the best fullstack DX I've ever seen and has such a brilliant API especially when combined with Zod. Zod and tRPC are some of the most
by johnmorrison 3y ago
I love tRPC, it's by far the best fullstack DX I've ever seen and has such a brilliant API especially when combined with Zod.
Zod and tRPC are some of the most important projects in the future of TS imho, I think we're gonna see a beautiful bloom of tRPC inspired DX across the TS space in coming years.
Two projects already have clearly have tRPC DNA attacking different use cases are Ping's UploadThing (https://github.com/pingdotgg/uploadthing https://github.com/pingdotgg/uploadthing) and our Lusat (https://github.com/lusatai/lusat https://github.com/lusatai/lusat).
- matthewfcarlson 3y agoI also recent did a personal project that uses tRPC and Zod and I agree that it was a fantastic experience. It also makes writing unit tests way easier.
- epolanski 3y agoI would also recomment effect/core + effect/schema, the pattern of creating typed services starting from schemas is there perfect for people that are more functional-programming leaning.
- johnmorrison 3y agoI saw that a while back, but it seems like a large learning curve and I don't immediately feel much drawing me towards it. Will be keeping an eye on it anyhow.
- MrJohz 3y agoDo you know of anything in this region for MongoDB? The two big problems there seem to be type-safe data CRUD, but also migration of data. I see people referencing Mongoose a lot, but that seems like it's a big downgrade from Zod/TS in terms of type safety.
- killthebuddha 3y agoI've never used it for Mongo, but Prisma is a pretty great type-safe ORM that supports Mongo: https://www.prisma.io/docs/getting-started https://www.prisma.io/docs/getting-started.
- killthebuddha 3y agoZod is...so freaking great. I'm feeling kind of hyperbolic at the moment, so I'll even go so far as: for a certain style of programming, adding Zod to a codebase is as big of a win as adding TypeScript.
- johnmorrison 3y agoAbsolutely. Zod is to the runtime what TypeScript is to the IDE.
- graftak 3y agoI don’t really like Zod at all, it has very finicky and verbose types/generic params and it’s object generic won’t allow you to pass a data type, but instead you must pass zods own schema types as properties which are very messy and unintuitive. Another annoyance is that the type of validation errors varies depending on what kind of schema you’re checking against. This makes it unpredictable to handle errors and there’s always too many edge cases. Lots of room for improvement.
- johnmorrison 3y agoI don't disagree (not that I feel the same level of annoyance, on balance I love Zod for the time it saves me) but what would you recommend as an alternative? The new valibot.dev looks cool but I haven't tried it yet.
- graftak 3y agoJust took a quick glance at the source[0] and the generic type for an object schema is a record of other schemas too, similar to Zod. At least that irk won't be solved by this and for me at least it’t the biggest one because it makes typing a function with generic data that includes a schema that acts upon it unnecessarily difficult. [0] https://github.com/fabian-hiller/valibot/blob/e6c53c8a4b0033274eef7e8fc70cdd65e46de7c1/library/src/schemas/object/object.ts#L21 https://github.com/fabian-hiller/valibot/blob/e6c53c8a4b0033...
- ShadowBanThis01 3y agoI just checked out the Zod intro pages but I still don’t know what problem it’s trying to solve. What is it adding to TypeScript (which I am not conversant in either)? Thanks for any insight!
- johnmorrison 3y agoruntime
- ShadowBanThis01 3y ago"Runtime" is not a problem.
- johnmorrison 3y agoTypeScript-first schema validation with static type inference
- ShadowBanThis01 3y agoThere you go. But schemas for what?
- 9935c101ab17a66 3y ago> Schema validation provides assurance that data is strictly similar to a set of patterns, structures, and data types you have provided. It helps identify quality issues earlier in your codebase and prevents errors that arise from incomplete or incorrect data types. From: https://blog.logrocket.com/schema-validation-typescript-zod/ https://blog.logrocket.com/schema-validation-typescript-zod/ Most common use case I’ve seen is using schema validation for user input (like forms) so you don’t send junk off to the api, you can validate data at runtime (whereas typescript checks your types statically when compiled).
- ShadowBanThis01 3y ago