-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment: Websockets #1545
Experiment: Websockets #1545
Conversation
At this moment it seems that the feature should probably be a separate package. |
Actually, it's kinda OK, because otherwise there is no way to ensure that ack callback would be called. |
closing this PR in order to continue in a separate repo: |
Exploring the possibilities based on the discussion: #991
In the end I moved it to a separate repo: https://github.com/RobinTail/zod-sockets
Concept
socket.io
library as on optional peer dependency for the best quality service including acknowledgements (I believe it's an important feature).attachSockets()
method on thehttpServer
or thehttpsServer
returned by thecreateServer()
method;Actions
having validation schemas for the incoming payload and the outgoing acknowledgement (optional), similar toEndpoint
.Endpoint
, are notz.object()
, butz.tuple()
.ActionsMap
, a dictionary associating the incoming event names with their handlers, similar toRouting
.ActionsFactory
(similar to theEndpointsFactory
).EmissionMap
— a dictionary associating the outgoing event names with their payload validation schemas (including acknowledgements, optional).Action
produced on theActionsFactory
aware of the available events, the payload constraints of which is ensured by the methodemit()
provided for theAction
's handler.attachRouting
method also requires theemission
for ensuring constraints on the offered features:onConnection
,onDisconnect
andonAnyEvent
which are having the same type asAction
handlers and equipped with theemit()
method, allowing customizations.Next