Replies: 5 comments 2 replies
-
Hello @aaronvg , I did not use tRPC myself, but once I got familiar with its concept. Libraries have similar goals, but there is a number of differences. I like the description of routes in my library more. Although it is possible that the tRPC solution is more plug-and-play. I'd be curious, please let me know :) |
Beta Was this translation helpful? Give feedback.
-
I did end up trying trpc.io and ended up migrating to it since we do have a react app and it did seem like it solved a lot of our problems. It was nice to be able to export a single client type rather than each endpoint's types individually. Anyway thanks for sharing your library, definitely has other usecases. I agree the routing in your lib is much cleaner looking |
Beta Was this translation helpful? Give feedback.
-
Great, @aaronvg . Thank you for sharing. |
Beta Was this translation helpful? Give feedback.
-
@aaronvg , I'd like to inform you that I've improved exports of API types to the frontend. |
Beta Was this translation helpful? Give feedback.
-
tRPC is very nice for fullstack monorepo, related to frontend client think the main difference is that tRPC infer the structure of router with input & ouput types for each endpoint, resulted type is imported in frontend where this type structure can be used in client for specifying available routes and input, output data think for creating this type is enough const routing = {
endpoint,
};
type EndpointToInputOutput<T extends AbstractEndpoint> = {
input: z.input<ReturnType<T['getInputSchema']>>;
output: z.output<ReturnType<T['getOutputSchema']>>;
};
// of course here need implement also for methods
type RecursiveExtractTypes<T extends Routing> = {
[P in keyof T]: T[P] extends Routing
? RecursiveExtractTypes<T[P]>
: T[P] extends AbstractEndpoint ? EndpointToInputOutput<T[P]> : never
};
// and possible that for frontend client will be more util structure like { '/:app/file/upload': { post: { input: any, output: any } } }
export type BackendStructure = RecursiveExtractTypes<typeof routing>; more complex task is to write frontend client that will use this imported type but also in case with tRPC this client have |
Beta Was this translation helpful? Give feedback.
-
I haven't dove into tRPC quite yet (I'm checking it out now) but would be curious to hear what you think of that project!
Beta Was this translation helpful? Give feedback.
All reactions