seN49
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
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
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
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