Has anyone combined trpc with durable
Has anyone combined trpc with durable objects to create a nicer wrapper around the DO API?
14 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yeah, that makes sensse. I'm about halfway through building something very similar to that, but with trpc in front. I'd love to get your review on the code if you'd like. I just don't understand DOs that well.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I'm using trpc@10 as well. I didn't realize I could use their built-in fetch adaptor, though! That's good news
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I love this example. This is super helpful.
Oh... I now see what you mean by fetch redirects...
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
As in,
httpLink
cannot accept a custom fetch functionUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thanks for the guidance, @koudelkaa. I need to call it a night, here.But, I'll bring in your recommended executor tomorrow! I'm really excited about it.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
This isn't done, but it's a start:
https://gist.github.com/colelawrence/ba912db3cd1539ee820c3fe5e67654df
I need to actually incorporate your middlewares to catch the outbound fetch,
I will also want to add a zod validation layer for the storage, but I have some snippets from other places that should make that easy.
I havd some other experiments with websockets earlier on, but I realized that I won't need websockets for a little while anyway. So, I can add those to this interface later on.
Alright, ciao! 👋
Definitely some issues with my initial implementation's approach to creating context. I will have a better example to show later on after I've tried a few things
Fixed it up and made some nice adjustments. It seems to be working for my use cases. Here's a not very good RateLimiter using trpc:
And usage for another endpoint:
WDYT @koudelkaa?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View