···7979 user_uuid: uuid.Uuid,
8080 registry: group_registry.GroupRegistry(msg.Msg),
8181) -> response.Response(mist.ResponseData) {
8282- case setup_initial_state(ctx, user_uuid) {
8282+ case fetch_user_data(ctx, user_uuid) {
8383 Error(err) -> handle_error(err)
8484 Ok(state) ->
8585 case request.path_segments(req) {
···9999}
100100101101/// Queries the Database and builds the initial state of the user
102102-fn setup_initial_state(
102102+fn fetch_user_data(
103103 ctx: Context,
104104 user_uuid: uuid.Uuid,
105105) -> Result(State, WebSocketError) {
···238238 }
239239}
240240241241+/// Build and send a `json` response through the socket connection.
242242+///
243243+/// ## Example
244244+///
245245+/// ```jsonc
246246+/// {
247247+/// "data_type": "occurrence:new",
248248+/// "data": {}, // <- Response data
249249+/// "meta": {
250250+/// "timestamp": 1764288924,
251251+/// "request_id": "9f6cc07b-3542-4adc-8edc-016056da9e53"
252252+/// }
253253+/// }
254254+/// ```
241255fn send_envelope(
242256 state state: State,
243257 conn conn: mist.WebsocketConnection,
+1-1
src/app/web/socket/envelope.gleam
···22import gleam/time/timestamp
33import youid/uuid
4455-/// Wrapper for data sent a websocket connection
55+/// Wrapper for data sent through a websocket connection
66pub type Envelope {
77 Envelope(
88 /// Used by the client to determine the type of message