seN49
seN49
TtRPC
Created by seN49 on 11/10/2023 in #❓-help
Tranform output data using middleware after handler has run - possible?
Found a reddit link with a similar use case... Here the OP wants to enrich the return type: https://www.reddit.com/r/sveltejs/comments/12n376g/type_error_trpc_middleware_enriching_result/ No solution though
2 replies
TtRPC
Created by T on 10/18/2023 in #❓-help
tRPC middleware infer type from another protectedProcedure
I've found using procedure works better for types than the middleware. If you change your middleware and use .use it should probably work as you expect!
2 replies
TtRPC
Created by seN49 on 3/30/2023 in #❓-help
errorFormatter ignored when using appRouter.createCaller
4 replies
TtRPC
Created by seN49 on 2/27/2023 in #❓-help
async createContext for Express Adapter
Just for completion sake... I was sure it had something to do with CORS i kept seeing undefined context and then delayed the correct context. Async didn t work, sync worked... The context code was something like this: () => { // do a bunch of stuff someFunction(() => {
return { user }; } return { user: undefined}; } tl;dr => there was another return path in the context from some earlier testing. Both returns would trigger eventually. but the initially one was the undefined, later on the internal function returned again haha
6 replies
TtRPC
Created by seN49 on 2/27/2023 in #❓-help
async createContext for Express Adapter
Yeah, can't seem to reproduce in the code sandbox. Will have to dig some more into it. Speaking of codesandbox, I couldn't get the express example to work at all initially, adding node-fetch polyfill seems to fix it though: https://codesandbox.io/s/sleepy-booth-rl1xqk?file=/src/client.ts import fetch from "node-fetch"; // @ts-ignore globalThis.fetch = fetch; I'll open a pr for it later
6 replies
TtRPC
Created by seN49 on 2/27/2023 in #❓-help
async createContext for Express Adapter
// Does not work, user is always undefined router.use( '/trpc', trpcExpress.createExpressMiddleware({ router: appRouter, createContext: () => someAsyncFunction(); }), );
6 replies
TtRPC
Created by seN49 on 2/27/2023 in #❓-help
async createContext for Express Adapter
// Works router.use( '/trpc', trpcExpress.createExpressMiddleware({ router: appRouter, createContext: () => { user: 'test' }, }), );
6 replies