wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:bulb: add documentation to `send_envelope` function

Kacaii f63b60c1 4f04cd01

+17 -3
+16 -2
src/app/web/socket.gleam
··· 79 79 user_uuid: uuid.Uuid, 80 80 registry: group_registry.GroupRegistry(msg.Msg), 81 81 ) -> response.Response(mist.ResponseData) { 82 - case setup_initial_state(ctx, user_uuid) { 82 + case fetch_user_data(ctx, user_uuid) { 83 83 Error(err) -> handle_error(err) 84 84 Ok(state) -> 85 85 case request.path_segments(req) { ··· 99 99 } 100 100 101 101 /// Queries the Database and builds the initial state of the user 102 - fn setup_initial_state( 102 + fn fetch_user_data( 103 103 ctx: Context, 104 104 user_uuid: uuid.Uuid, 105 105 ) -> Result(State, WebSocketError) { ··· 238 238 } 239 239 } 240 240 241 + /// 󱃜 Build and send a `json` response through the socket connection. 242 + /// 243 + /// ## Example 244 + /// 245 + /// ```jsonc 246 + /// { 247 + /// "data_type": "occurrence:new", 248 + /// "data": {}, // <- Response data 249 + /// "meta": { 250 + /// "timestamp": 1764288924, 251 + /// "request_id": "9f6cc07b-3542-4adc-8edc-016056da9e53" 252 + /// } 253 + /// } 254 + /// ``` 241 255 fn send_envelope( 242 256 state state: State, 243 257 conn conn: mist.WebsocketConnection,
+1 -1
src/app/web/socket/envelope.gleam
··· 2 2 import gleam/time/timestamp 3 3 import youid/uuid 4 4 5 - /// 󰛮 Wrapper for data sent a websocket connection 5 + /// 󰛮 Wrapper for data sent through a websocket connection 6 6 pub type Envelope { 7 7 Envelope( 8 8 /// 󱤇 Used by the client to determine the type of message