Skip to content

Commit

Permalink
remove ws handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Nov 21, 2024
1 parent 824f619 commit 50074ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
10 changes: 8 additions & 2 deletions packages/frontend/src/api/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,30 @@ const app = new OpenAPIHono<HonoEnv>()
description: "Server Sent Events",
content: {
"text/event-stream": {
schema: z.string(),
schema: z.any(),
},
},
},
401: authResponses[401],
},
}),
async (c) => {
return streamSSE(c, async (stream) => {
const sseRes = streamSSE(c, async (stream) => {
ee.on("invalidate", (data) =>
stream.writeSSE({
data: JSON.stringify(data),
event: "invalidate",
id: ulid(),
}),
);

stream.onAbort(() => {
ee.off("invalidate");
});
// biome-ignore lint/complexity/noBannedTypes: <explanation>
}) as unknown as TypedResponse<{}, 200, string>;

return sseRes;
},
)
.doc31("/api/docs/openapi.json", {
Expand Down
15 changes: 0 additions & 15 deletions packages/frontend/src/trpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ export const queryClient = new QueryClient({
},
},
});
try {
// add websocket listener
const ws = new WebSocket(
`ws${backendUrl.protocol === "https:" ? "s" : ""}://${backendUrl.host}/api/ws`,
);

ws.addEventListener("message", (event) => {
const data = JSON.parse(event.data) as QueryKey;
queryClient.invalidateQueries({
queryKey: data,
});
});
} catch (error) {
console.error(error);
}

export const appClient = hc<AppType>(
`${backendUrl.protocol}//${backendUrl.host}/`,
Expand Down

0 comments on commit 50074ed

Please sign in to comment.