I am a Dev
Hello, is there any way to create a base router with common procedures? like an interface
I want all routers that use it have the state procedure (subscriptions), so I can create a common hook later
Although the implementation of the methods is completely different on each router, I just want to guarantee that they have those procedures, like an interface
The hook basically will subscribe to the state on mount, and unsubscribe on unmount
Thanks
8 replies
Review of inner and outer context with express
Hello, I didn't find any example that uses inner (for testing) and outer context with express.
That's how I implemented it for my express trpc boilerplate, I wanted to know if I did it right, or if there was some error.
Thank you so much
TLDR;
The inner context and options is a custom object with partial express options.
the outer context and options is an extension of the inner but now the express options are mandatory.
2 replies
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
2 replies
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
5 replies
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.
It's the first time I am creating a server, for now it will be deployed on a PC on an intranet.
It's just a server to everyone in the intranet can access and modify a json file.
Thanks
4 replies