OtterSwims996
OtterSwims996
Explore posts from servers
TtRPC
Created by OtterSwims996 on 3/19/2024 in #❓-help
does anyone know how put vs post calls map to the trpc procedures provided? (query vs mutation)
I see, I'll give that a shot
5 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
Hi Nico, apologies for the late response. I took a break from working on typscript so i didn't check this thread. Glad you were able to get it working with the page router! Were you able to get clerk working with sockets? I was running into issues when i tried it myself with my page router setup, sharing some details from a thread i created on the clerk support channel here: https://discord.com/channels/856971667393609759/1200260793447485610/1204980669407694948
13 replies
TTCTheo's Typesafe Cult
Created by Deras on 9/26/2023 in #questions
Looking for 1-3 hour long Next tutorial, app router, server comp., server actions, local db, auth.js
Have you considered just taking a shortcut and using Clerk? It uses nextauth under the hood and seems to be much less work to implement
16 replies
TTCTheo's Typesafe Cult
Created by migs on 1/31/2024 in #questions
TRPC Security/ Authorization Concerns
I think you'll have to write your own code to give users permissions in your db. You can probably write some more code in your middleware file to check requests against the roles you've given the users in your db in order to allow or disallow them. You can probably insert the role they have into the context you pass along in your middleware and then return the proper TRPC error code on your router functions
13 replies
TtRPC
Created by OtterSwims996 on 1/17/2024 in #❓-help
Unable to set up a client side subscription to a trpc route that supports websockets
I have been able to fix this issue by using a function to return the correct link in the links array. It seems that the links are something that are mainly evaluated on the client side, and wsLink as well as httpBatchLink are "terminating links" which means that we cannot consecutively put a wslink after a httpBatchLink or vice versa. I borrowed a code snippet from this example project which returns the right link based on the browser having a window. https://github.com/trpc/examples-next-prisma-websockets-starter/blob/c666de6367d7449d4108e5e384da043c4f93a5d5/src/utils/trpc.ts#L21-L43 Its also possible to return the right link based on the operation type as is done here: https://github.com/apollographql/subscriptions-transport-ws/issues/333
5 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
I have been able to fix this issue by using a function to return the correct link in the links array. It seems that the links are something that are mainly evaluated on the client side, and wsLink as well as httpBatchLink are "terminating links" which means that we cannot consecutively put a wslink after a httpBatchLink or vice versa. I borrowed a code snippet from this example project which returns the right link based on the browser having a window. https://github.com/trpc/examples-next-prisma-websockets-starter/blob/c666de6367d7449d4108e5e384da043c4f93a5d5/src/utils/trpc.ts#L21-L43 Its also possible to return the right link based on the operation type as is done here: https://github.com/apollographql/subscriptions-transport-ws/issues/333
13 replies
TtRPC
Created by OtterSwims996 on 1/17/2024 in #❓-help
Unable to set up a client side subscription to a trpc route that supports websockets
it seems that httpbatchlink is a terminating link that is causing my request to never be routed to the wslink that is in my links array: https://trpc.io/docs/client/links#the-terminating-link so i will have to use splitlink or some conditional logic like i see is used here in this sample project https://github.com/trpc/examples-next-prisma-websockets-starter/blob/077367508a7dcda504170b48bc7b6c65457f90c6/src/utils/trpc.ts#L18-L40
5 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
i think i know what is wrong, i have to do some configuration around the links used in api.ts, it is something that is part of trpc that i haven't really grasped till now: https://github.com/apollographql/subscriptions-transport-ws/issues/333 I have to figure out how best to implement the link array and use a split if necessary, because this link array seems to be used both by server and client So depending on where it's evaluated I need to be returning either wslink or batch link I have to take into account ssr as well..
13 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
I looked more closely at the errors i was seeing in the console, and this is what i see:
TRPCClientError: Subscriptions should use wsLink
at TRPCClientError.from (webpack-internal:///./node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs:44:16)
at eval (webpack-internal:///./node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs:139:81)
TRPCClientError: Subscriptions should use wsLink
at TRPCClientError.from (webpack-internal:///./node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs:44:16)
at eval (webpack-internal:///./node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs:139:81)
13 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
I believe i'm using page router only, i'm not sure how to check though I'm not using next auth just yet, but i was going to implement it later. I have been thinking that maybe i should just start from someone elses existing base project like here and just use that: https://github.com/Lada496/my-t3-twitter-lite it seems to already be using prisma and next auth along with sockets. I found it on this medium post here: https://medium.com/@lada496/trpc-102-subscription-web-socket-d81b8962a010
56 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
56 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
13 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
No description
13 replies
TTCTheo's Typesafe Cult
Created by OtterSwims996 on 1/17/2024 in #questions
Unable to set up a client side subscription to a trpc route that supports websockets
I would like to note that the other endpoints work, i can see that sending data to the server through a regular mutation query works just fine and i can print out the input on the backend. Its just that: - my events dont seem to be triggering the event listener that i setup on the websocket subscription endpoint - the client gets two hydration errors upon querying the subscription endpoint
13 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
56 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
No description
56 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
Hey thanks for checking in, i think i was able to successfully get my websocket set up and running, since i see a "ws con established" log message on my client, but i dont seem to be able to trigger events on my backend to send information to the front end :/
56 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
thanks for sharing your code snippets and solutions
56 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
i will try what i can for now
56 replies
TTCTheo's Typesafe Cult
Created by cidit on 12/10/2023 in #questions
im having trouble setting up trpc w/ websockets on latest t3...
okay sure
56 replies