|
Hi, and thanks for both zod-sockets and express-zod-api — using them together. My use case: the socket is a push-only channel. All mutations happen over the REST layer (express-zod-api), and after a successful mutation I want to emit a typed event to a room (e.g. emitBusiness(id, "updateRequest", dto)). I never receive events from clients — no Actions, no RPC. What I found: The express-zod-api integration section covers sharing the same HTTP server (attachSockets({ target: servers.pop()! })), but not how to emit from an HTTP handler.
|
Replies: 1 comment
|
Hello, @giovio For what you've described I'd also suggest to consider a bit simpler SSE approach that is available in Express Zod API: Regarding your questions:
It was not supposed to "emit elsewhere in your app". For the cases like this, the idea was to keep the emission inside the
I like the second suggestion (returning it from the
I'd prefer to avoid that due to the everything said above and because that the interface is generic. |
Hello, @giovio
For what you've described I'd also suggest to consider a bit simpler SSE approach that is available in Express Zod API:
https://ez.robintail.cz/v28.7.5/subscriptions
Doing that, you'd only have to maintain the "room" of those to notify.
Regarding your questions:
It was not supposed to "emit elsewhere in your app". For the cases like this, the idea was to keep the emission inside the
onStartuphook while also interacting with other parts of the application via an EventEmitter or similar. Your Express Zod API endpoint could emit an internal even…