aryzing
Can middleware be used on a router?
Given a router where all procedures need to use the same middleware, can the middleware be somehow attached to the router instead of manually to routes?
For example, given an "admin" router, it would be quite catastrophic if one of the endpoints was accidentally set up with a
publicProcedure
instead of adminProcedure = publicProcedure.use(isAdmin)
.4 replies
Feature or happy accident: error message from `cause` being used as TRPC's error message
When a procedure throws a TRPC error with no message, it turns out that if the thrown error has a cause, and the cause has a message, the cause's message will be used as the TRPC error message returned to the client. Is this on purpose or an accident? Couldn't find this behavior documented.
2 replies
How to configure context for a standalone server?
Are there any examples out there on how to set up context for a standalone server? The docs do include an example for
next
, although it doesn't help much in setting one up for a standalone server.
How is context set up for a standalone server?6 replies
Docs hard to follow with so much `next` code
Not having a great experience with the docs. There are many examples that use
next
, making it hard to understand what should be done in cases where next
isn't being used. Take the docs on setting up the context
: https://trpc.io/docs/server/context. They're entirely next
focused. To what extent is Vercel's sponsorship affecting the docs?3 replies
How to make typed error responses in the context of a specific query?
Each query has a typed (success) response, although it seems all queries have a shared type for the error response. Is there a way of having per-query typed error responses? Is there a better alternative to having an error within a successful response, as below?
2 replies