Indeed
Indeed5mo ago

Serving files with TRPC and Express

Hi! Is there any way to serve files using express while using trpc typed way? As in using
app.get<{filename: string}>('/assets', /* send file response */ );
app.get<{filename: string}>('/assets', /* send file response */ );
but also being able to do on the client
trpc.assets.query({filename: 'test'})
trpc.assets.query({filename: 'test'})
instead of having to split between two solutions
1 Reply
NeoBean
NeoBean5mo ago
I believe trpc doesn't handle file responses. What you'd do instead is transmit a file link via the api and invoke the link (signed for security) to download/serve the file.