I am a DevI
tRPC3y ago
1 reply
I am a Dev

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.

So should I put in the context the API key rotator class?

And this should be a singleton like the db instance?

Also the API key rotator has dependency on the db, to store the last used API key, and consult all API keys.


Thanks
Was this page helpful?