jack
error route always getting 500 from trpc error? (next13/approuter)
I've got this condition for throwing in my trpc procedure:
and on client I have a next13
error.tsx
route, in which I do:
errorCode
is always 500 when we throw from that condition. No matter the code I pass when I throw6 replies
best practices for organizing routes/procedures?
i'm trying to find some practices/styles in which people generally define routes with trpc. currently im just doing a router per data entity, and defining crud operations on there, but there's a lot of caveats that are kind of defined with REST, that i'm unsure of how to handle here.
one idea i had was to define my router as such: (assume each subrouter will have routes)
another thing is reusing logic- i have a getSelectionsById, and a getOwnSelections. of course, these are gonna have a lot overlap because its entirely the same logic, but in one i'm passing conditional ids, and in the other im passing the session id. of course i could extract this out, but it feels inconsistent with the rest of the logic living inside of the router.
i'm sure there's no clear cut answer for most of this, but i was just wondering how people generally go about this, or if there are any guides or blogs about this topic.
4 replies
type mismatch between tRPC return (in sveltekit) and defined type
i've got this piece of code:
the issue is that the type of res, as returned from trpc, is
SerializeObject<UndefinedToOptional<Card & { tasks: Task[]; }>>[]
, while i've type my cards state as (Card & { tasks: Task[]; })[];
. as far as i can tell, there should be no mismatch in type here, but the linter isn't happy with trying to pass res
as the same type as cards
13 replies