···11-import app/web/socket/message as msg
11+import app/web/socket/message
22import gleam/erlang/process
33import group_registry
44import pog
5566/// Holds any additional data that the request handlers need in addition to the request:
77-/// Like API Keys, configurations, database connections, and others
77+/// Like configurations, database connections, and others
88pub type Context {
99 Context(
1010+ /// BEAM's private directory for static files
1011 static_directory: String,
1212+ /// Postgres's connection pool
1113 db: pog.Connection,
1414+ /// Key for encryption and decryption
1215 secret_key_base: String,
1313- registry_name: process.Name(group_registry.Message(msg.Msg)),
1616+ /// Process registry
1717+ registry_name: process.Name(group_registry.Message(message.Msg)),
1818+ /// Enviroment where the code is running on
1419 env: Enviroment,
1520 )
1621}
17221818-/// Enviroment where the code is running on
2323+/// Enviroment where the code is running on
1924pub type Enviroment {
2025 /// Code is running locally
2126 Dev
+3-3
src/app/web/socket.gleam
···9595 user_uuid: uuid.Uuid,
9696 registry: group_registry.GroupRegistry(msg.Msg),
9797) -> Response {
9898- case fetch_user_data(ctx, user_uuid) {
9898+ case build_initial_state(ctx, user_uuid) {
9999 Error(err) -> handle_error(err)
100100 Ok(state) -> route_request(req, ctx, registry, state)
101101 }
···344344 #(state, Some(selector))
345345}
346346347347-/// Queries the Database and builds the initial state of the user
348348-fn fetch_user_data(
347347+/// Queries the Database and builds the initial state of the connection
348348+fn build_initial_state(
349349 ctx: Context,
350350 user_uuid: uuid.Uuid,
351351) -> Result(State, WebSocketError) {