{"action":"created","comment":{"url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/comments/227679568","pull_request_review_id":167774399,"id":227679568,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzY3OTU2OA==","diff_hunk":"@@ -0,0 +1,29 @@\n+# frozen_string_literal: true\n+\n+require 'colmena/command'\n+\n+module RealWorld\n+  module Api\n+    module Commands\n+      class ApiUpdateCurrentUser < Colmena::Command\n+        def call(auth_token:, email: nil, username: nil, bio: nil, image: nil)\n+          token, error = port(:tokens).decode_auth(auth_token)\n+          return error_response(:forbidden, reason: error) if error\n+\n+          updated_user = port(:router).command(:update_user).call(\n+            id: token.fetch(:user_id),\n+            email: email,\n+            username: username,\n+            bio: bio,\n+            image: image,\n+          )\n+\n+          capture_errors(updated_user) do\n+            user = updated_user.fetch(:data)\n+            response(user: user.merge(token: auth_token))\n+          end\n+        end\n+      end\n+    end\n+  end\n+end","path":"lib/real_world/api/commands/api_update_current_user.rb","position":29,"original_position":29,"commit_id":"1ea823ea452c55a70458b06ebb46b22d989df128","original_commit_id":"1ea823ea452c55a70458b06ebb46b22d989df128","user":{"login":"larribas","id":3601671,"node_id":"MDQ6VXNlcjM2MDE2NzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3601671?v=4","gravatar_id":"","url":"https://api.github.com/users/larribas","html_url":"https://github.com/larribas","followers_url":"https://api.github.com/users/larribas/followers","following_url":"https://api.github.com/users/larribas/following{/other_user}","gists_url":"https://api.github.com/users/larribas/gists{/gist_id}","starred_url":"https://api.github.com/users/larribas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larribas/subscriptions","organizations_url":"https://api.github.com/users/larribas/orgs","repos_url":"https://api.github.com/users/larribas/repos","events_url":"https://api.github.com/users/larribas/events{/privacy}","received_events_url":"https://api.github.com/users/larribas/received_events","type":"User","site_admin":false},"body":"I think the filesystem makes for a pretty natural command/query/listener index. This is what I've experienced with our particular ruby codebase:\r\n\r\n* I want to jump to a query. I usually know the name of the query. If all queries are in the same file, I need to start thinking in terms of which cell they're in, and whether it's a query or a command, so mentally is takes me a bit longer.\r\n* This way I immediately know which cells are tested and can go to that spec.\r\n* This way I can remove a command almost without any hassle.\r\n* This way I can add a new command without worrying about the order of declarations within the same file, and so on.\r\n\r\nIt's probably related to the way I move with vim/emacs too, but I think it's a nicer structure for Colmena.\r\n\r\nWhen I think about doing the same thing in Elm/Haskell, it seems quite overkill, but then again I would need to make sure my [ctags](https://en.wikipedia.org/wiki/Ctags) are set up properly if I want to remain this productive.","created_at":"2018-10-24T08:01:21Z","updated_at":"2018-10-24T08:01:22Z","html_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app/pull/24#discussion_r227679568","pull_request_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/comments/227679568"},"html":{"href":"https://github.com/schoolhouse-io/colmena-realworld-example-app/pull/24#discussion_r227679568"},"pull_request":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24"}},"in_reply_to_id":227637886},"pull_request":{"url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24","id":224535326,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0NTM1MzI2","html_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app/pull/24","diff_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app/pull/24.diff","patch_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app/pull/24.patch","issue_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/24","number":24,"state":"closed","locked":false,"title":"Expose profile and follow","user":{"login":"larribas","id":3601671,"node_id":"MDQ6VXNlcjM2MDE2NzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3601671?v=4","gravatar_id":"","url":"https://api.github.com/users/larribas","html_url":"https://github.com/larribas","followers_url":"https://api.github.com/users/larribas/followers","following_url":"https://api.github.com/users/larribas/following{/other_user}","gists_url":"https://api.github.com/users/larribas/gists{/gist_id}","starred_url":"https://api.github.com/users/larribas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larribas/subscriptions","organizations_url":"https://api.github.com/users/larribas/orgs","repos_url":"https://api.github.com/users/larribas/repos","events_url":"https://api.github.com/users/larribas/events{/privacy}","received_events_url":"https://api.github.com/users/larribas/received_events","type":"User","site_admin":false},"body":"I've exposed the remaining user and profile endpoints and made some opinionated refactors, such as:\r\n\r\n- Commands and queries are stored and registered in the same way for all cells, including the API cell. Since there will be a big index of c/q that are required and registered, I believe it is better to keep it isolated but together (it favors quick find, delete, add, and rename ops).\r\n- Router and event broker implementation don't need extra tech-dependent considerations such as attributes or channels, and the names they use are not tied to any technology.\r\n- I've reverted to the `bio` and `image` attributes being non-nullable. I didn't realize when I merged your PR, but there is a dichotomy we need to address gracefully. This is what I wrote for the commit description:\r\n\r\n> nil represents \"i don't care about this attribute\", whereas the empty string\r\nmeans \"i explicitly want this optional attribute to be empty\". I think this\r\nmakes sense because it follows a commonplace distinction between zero values and\r\nnil pointers that comes from low-level languages like C or Go.\r\n\r\nIf we were to use `nil` to represent optional attributes in the domain we would need a custom type `Unspecified` in the HTTP pipeline.\r\n\r\nLet me know what you think ;)","created_at":"2018-10-21T11:41:17Z","updated_at":"2018-10-24T08:01:22Z","closed_at":"2018-10-24T04:29:33Z","merged_at":"2018-10-24T04:29:33Z","merge_commit_sha":"992eb5a37cfa0d7b843237cbd05c467a122f1796","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24/commits","review_comments_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24/comments","review_comment_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/24/comments","statuses_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/statuses/1ea823ea452c55a70458b06ebb46b22d989df128","head":{"label":"schoolhouse-io:expose-profile-and-follow","ref":"expose-profile-and-follow","sha":"1ea823ea452c55a70458b06ebb46b22d989df128","user":{"login":"schoolhouse-io","id":44120742,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MTIwNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/44120742?v=4","gravatar_id":"","url":"https://api.github.com/users/schoolhouse-io","html_url":"https://github.com/schoolhouse-io","followers_url":"https://api.github.com/users/schoolhouse-io/followers","following_url":"https://api.github.com/users/schoolhouse-io/following{/other_user}","gists_url":"https://api.github.com/users/schoolhouse-io/gists{/gist_id}","starred_url":"https://api.github.com/users/schoolhouse-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schoolhouse-io/subscriptions","organizations_url":"https://api.github.com/users/schoolhouse-io/orgs","repos_url":"https://api.github.com/users/schoolhouse-io/repos","events_url":"https://api.github.com/users/schoolhouse-io/events{/privacy}","received_events_url":"https://api.github.com/users/schoolhouse-io/received_events","type":"Organization","site_admin":false},"repo":{"id":152893481,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI4OTM0ODE=","name":"colmena-realworld-example-app","full_name":"schoolhouse-io/colmena-realworld-example-app","private":false,"owner":{"login":"schoolhouse-io","id":44120742,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MTIwNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/44120742?v=4","gravatar_id":"","url":"https://api.github.com/users/schoolhouse-io","html_url":"https://github.com/schoolhouse-io","followers_url":"https://api.github.com/users/schoolhouse-io/followers","following_url":"https://api.github.com/users/schoolhouse-io/following{/other_user}","gists_url":"https://api.github.com/users/schoolhouse-io/gists{/gist_id}","starred_url":"https://api.github.com/users/schoolhouse-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schoolhouse-io/subscriptions","organizations_url":"https://api.github.com/users/schoolhouse-io/orgs","repos_url":"https://api.github.com/users/schoolhouse-io/repos","events_url":"https://api.github.com/users/schoolhouse-io/events{/privacy}","received_events_url":"https://api.github.com/users/schoolhouse-io/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app","description":"Exemplary real world JSON API built with Colmena (Ruby) https://realworld.io/","fork":false,"url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app","forks_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/forks","keys_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/teams","hooks_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/hooks","issue_events_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/events{/number}","events_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/events","assignees_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/assignees{/user}","branches_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/branches{/branch}","tags_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/tags","blobs_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/statuses/{sha}","languages_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/languages","stargazers_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/stargazers","contributors_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/contributors","subscribers_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/subscribers","subscription_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/subscription","commits_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/contents/{+path}","compare_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/merges","archive_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/downloads","issues_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues{/number}","pulls_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls{/number}","milestones_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/milestones{/number}","notifications_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/labels{/name}","releases_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/releases{/id}","deployments_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/deployments","created_at":"2018-10-13T16:51:06Z","updated_at":"2018-10-24T04:29:36Z","pushed_at":"2018-10-24T04:29:34Z","git_url":"git://github.com/schoolhouse-io/colmena-realworld-example-app.git","ssh_url":"git@github.com:schoolhouse-io/colmena-realworld-example-app.git","clone_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app.git","svn_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app","homepage":null,"size":99,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"schoolhouse-io:master","ref":"master","sha":"dd6fd443b38af40d9f2c7c4621010ddda4db7ec8","user":{"login":"schoolhouse-io","id":44120742,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MTIwNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/44120742?v=4","gravatar_id":"","url":"https://api.github.com/users/schoolhouse-io","html_url":"https://github.com/schoolhouse-io","followers_url":"https://api.github.com/users/schoolhouse-io/followers","following_url":"https://api.github.com/users/schoolhouse-io/following{/other_user}","gists_url":"https://api.github.com/users/schoolhouse-io/gists{/gist_id}","starred_url":"https://api.github.com/users/schoolhouse-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schoolhouse-io/subscriptions","organizations_url":"https://api.github.com/users/schoolhouse-io/orgs","repos_url":"https://api.github.com/users/schoolhouse-io/repos","events_url":"https://api.github.com/users/schoolhouse-io/events{/privacy}","received_events_url":"https://api.github.com/users/schoolhouse-io/received_events","type":"Organization","site_admin":false},"repo":{"id":152893481,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI4OTM0ODE=","name":"colmena-realworld-example-app","full_name":"schoolhouse-io/colmena-realworld-example-app","private":false,"owner":{"login":"schoolhouse-io","id":44120742,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MTIwNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/44120742?v=4","gravatar_id":"","url":"https://api.github.com/users/schoolhouse-io","html_url":"https://github.com/schoolhouse-io","followers_url":"https://api.github.com/users/schoolhouse-io/followers","following_url":"https://api.github.com/users/schoolhouse-io/following{/other_user}","gists_url":"https://api.github.com/users/schoolhouse-io/gists{/gist_id}","starred_url":"https://api.github.com/users/schoolhouse-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schoolhouse-io/subscriptions","organizations_url":"https://api.github.com/users/schoolhouse-io/orgs","repos_url":"https://api.github.com/users/schoolhouse-io/repos","events_url":"https://api.github.com/users/schoolhouse-io/events{/privacy}","received_events_url":"https://api.github.com/users/schoolhouse-io/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app","description":"Exemplary real world JSON API built with Colmena (Ruby) https://realworld.io/","fork":false,"url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app","forks_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/forks","keys_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/teams","hooks_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/hooks","issue_events_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/events{/number}","events_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/events","assignees_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/assignees{/user}","branches_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/branches{/branch}","tags_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/tags","blobs_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/statuses/{sha}","languages_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/languages","stargazers_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/stargazers","contributors_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/contributors","subscribers_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/subscribers","subscription_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/subscription","commits_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/contents/{+path}","compare_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/merges","archive_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/downloads","issues_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues{/number}","pulls_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls{/number}","milestones_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/milestones{/number}","notifications_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/labels{/name}","releases_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/releases{/id}","deployments_url":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/deployments","created_at":"2018-10-13T16:51:06Z","updated_at":"2018-10-24T04:29:36Z","pushed_at":"2018-10-24T04:29:34Z","git_url":"git://github.com/schoolhouse-io/colmena-realworld-example-app.git","ssh_url":"git@github.com:schoolhouse-io/colmena-realworld-example-app.git","clone_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app.git","svn_url":"https://github.com/schoolhouse-io/colmena-realworld-example-app","homepage":null,"size":99,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24"},"html":{"href":"https://github.com/schoolhouse-io/colmena-realworld-example-app/pull/24"},"issue":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/24"},"comments":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/schoolhouse-io/colmena-realworld-example-app/statuses/1ea823ea452c55a70458b06ebb46b22d989df128"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"larribas"}}