tRPC

T

tRPC

Move Fast & Break Nothing. End-to-end typesafe APIs made easy.

Join

it sound like handle upload/download file need build new http server or endpoint?

I have scan all posts i can about solution for handle upload/download file with trpc.So there is no great solution for this with trpc for now? If no, i can only build new nestjs server to handle files specially but i need implement permission management again and can't reuse middleware that used in trpc. By the way, trpc is a Wonderful project for ts full stack developer!...
Solution:
not sure what you're using for file storage. we use S3 Buckets on our project and we have our tRPC endpoitn generate a pre-signed URL for S3 Uploads that gets sent to the frontend, and the file is uploaded directly from client to S3 downloads work similarly where we can generate presigned url's if the bucket is not public, or just give them the public link if it is...

tRPC queries running on the server

Environment: - bun 1.0.2 - next 13.4.16 - trpc 10.37.1 ...

Name recommendations for my api endpoints that use swagger, trpc-panel, trpc-playground.

What name do you recommend for each one, in addition to the rest api and the trpc api endpoints. Like /api /trpc...

In the context should I put all my dependencies for my endpoint handlers?

For example I have the end point 'getStuff` In this endpoint the handler call 3 party apis and map the data to the tRPC output. But I have an API key rotator class, to do each request to a 3 party API with the different API key in each request....

Basic Inference not Working

I have been struggling to get basic type inferencing to work with trpc, react, and Drizzle ORM. This is what my server-side router is returning from the list method: ``` export const organizationRouter = router({...

tRPC Websockets with a standalone Bun Server?

Hey folks! Experiementing with setting up a standalone tRPC Server using Bun. The HTTP part is great - i'm wondering if anyone has succeeded getting it to work with Bun's websocket server? if not, i'll continue figuring it out and hopefully add an adapter to tRPC....

Infinite session query when tab is in background

So, when I am in development mode, doing some changes in my code and my application's tab is not in focus, then there is an infinite loop of session query. I can see the query running in my logs. I don't know what the reason it. Can anyone please help me.
No description

How to return a stream? like open ai api

I want that my api can have stream responses like open ai https://github.com/openai/openai-node#streaming-responses how can i do it? Thanks...

was wondering if anyone got a chance to use Ajv as input/output validator?

I have been trying to use Ajv https://ajv.js.org/ with tRPC, but I wasn't able to get the types working, no matter what I do the input type is always boolean, regardless of the schema I am using.

state change does not refetch the query and the app freezes

https://github.com/trpc/trpc/discussions/4856 I am not sure if linking is allowed but I opened a discussion in the repo and have gotten no responses. I am hoping someone here can help me. It is very likely a mistake on my part and would really appreciate it if someone could point me in the right direction....

trpc subscription with react-query

TRPCClientError: Subscriptions should use wsLink having error when use subscription with react-query ...

Unable to get mutation to trigger subscription because EventEmitter not being shared

Hey folks, Been struggling with this for a few hours now hopelessly and trying random things - read all related posts in this forum, on github issues, and stackoverflow - and still don't understand what is going on. I have a next app with a custom HTTP server and using tRPC. WSLink etc is all fine - i'm doing everything the proper way....

Is there a guide of how to test?

I'm usually use vitest but in frontend of shared packages. I'm frontend trying to create my first api ๐Ÿ™‚ Thanks...

Modify the payload before mutating

I have a specific mutation hook that is used all throughout my app, and inside of the hook I want to modify the payload before it is sent to the server (to read something from local storage and add it to payload). Is this possible? I can't seem to find a way to do this. There also isn't a way AFAIK to modify the mutationFn with the nextjs adapter. My only solution would be redefining mutate and mutateAsync that are modified to do this preprocessing. Thanks!...

is there a simple boilerplate that has everything ready to deploy?

For example nodemon, reading the port for .env, etc. (I don't know if that's how it is haha) I use turborepo, so can be an internal package. But I want to see how the project configuration looks for the deploy....

Context is not fully globally accessed? [ probably newbie question ]

I create a context in the based procedure, but It's undefined in the procedure based on it. Also the opts.ctx doesn't exist before I create it, although I've used .context() upon initializing trpc, but that's no big deal. NVM I should've defined it upon server creation. Context defined by a procedure cannot be seen by another procedure?? how do I get around that?...

Using tRPC for server to server requests

Hey everyone! The start up Iโ€™m at recently deployed a server separate from our main server. Our main server uses a combination of tRPC and Express endpoints on Node 16.14.0. When we introduced this separate server we set up some functions to make requests from our main server to the separate server. The core of these functions is encrypting + compressing requests to the separate server as well as decrytping + decompressing on the separate server and then again on the way back (the response). This was setup with Express on both ends, but now weโ€™re wishing we had done it with tRPC! I saw this post: https://github.com/trpc/trpc/discussions/1566, and it gave me some reassurance about setting up a client on our main server to send requests over to the separate server....

ReferenceError: FormData is not defined

I am using the experimental form data as shown in the examples and it works correctly on my machine, but when deploying to DigitalOcean App Platform, I get the error you see below. ReferenceError: FormData is not defined in /node_modules/@trpc/server/dist/adapters/node-http/content-type/form-data/index.mjs for: ```javascript const formData = new FormData();...

TRPCError that has TRPCError as cause

Having some troubles with error handling, specifically, my errors are double-wrapped in a TRPCError. What I'm doing is basically having a mutation that does: ```...