marv 🍵
TTCTheo's Typesafe Cult
•Created by marv 🍵 on 7/6/2024 in #questions
New to the t3 stack and tRPC, how do I share code between route functions correctly?
Maybe I'm going about this the complete wrong way. Basically, as you can see below I am trying to create two different routes that share a lot of logic that I want to make into a function. I tried making a function outside of the
discordRouter
but I couldn't figure out how to type ctx
correctly, so any thoughts would be appreciated. What I've tried so far is import { type createTRPCContext } from "~/server/api/trpc";
then type Context = ReturnType<typeof createTRPCContext>;
but that's a promise for the context and I feel like I'm going about it the wrong way.
5 replies