JavascriptMick
Use onError to change an application error into a TRPCError?
I want to use the onError handler to change any instance of a custom application error into a TRPCError (I want the HTTP Status code to be a 401 rather than a 500). I tried this but it doesn't work...
nor does this
I can set individual properties on the error object like error.message but thought there might be an easier way. Has anybody got a nifty hack for this?
8 replies
is context cached?
If I put an object on the context that represents the User record from my database...
And then I have a router function which changes important details of the user....
Do I need to 'mutate' the dbUser on the context....
or will subsequent calls to routes, re-invoke createContext and re-load the user from the database?
7 replies
Best way to implement input based validation on a router procedure
Hi guys, bit of a noob. I have already created a 'protectedProcedure', ensuring the user is logged in, but for some of my procedures, I also want to ensure the user is an ADMIN for the account specified on the input. This is my first try with validation just added at the top of the procedure implementation...
Is there a way to implement this with multiple input parsers (https://trpc.io/docs/procedures#multiple-input-parsers) ?? what would that look like?
15 replies