Parity PR 5a: the admin JSON API (Erlang routes, through the desk entry points) #17
Loading…
Reference in a new issue
No description provided.
Delete branch "mercurius/4-pr5-facade"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs macula-services/mcl-bookclub-phoenix#4: parity PR 5 (the facade), first half. Gap table §D "admin JSON API: missing" and §F "admin over HTTP: thinner".
What
The Erlang twin's admin JSON API (
mcl_bookclub_admin.erl:30-34, 63-93), served by the Phoenix endpoint beside the LiveView console:POST /api/{plural}/{verb}: the nine commands, each through its desk's*_apientry point.200 {"ok":true,"version":v,"events":[...]}or400 {"ok":false,"error":reason}.GET /api/{clubs|members|books|readings}/:idandGET /api/members/:id/readings: the five QRY desks.200with the row, or404 {"ok":false,"error":reason}.404 {"error":"not_found"}, as E'sdispatch(_, _, _).MclBookclubPhoenixWeb.ClubName.enrich/1stamps the club's name into register and procure, as E'senrich_club_name/1(:100-108). It keeps a name the caller brings. The LiveView now calls the same module instead of its own private copy, so the console and the API cannot drift apart.Choices a reviewer may question
Plug.Parsers. E turns an unreadable body into empty params, and the desk then refuses the missing fields with a 400 JSON (decode/1,:124-135).Plug.Parserswould raiseParseError, and this endpoint'sErrorViewrenders HTML only. The:apipipeline therefore parses nothing.{labels, atom}. In Elixir a body key never becomes an atom, so only the route's own fields reach the entry point.inspect/1, because JSON has no tuples.Tests (
apps/mcl_bookclub_phoenix_web/test/admin_api_test.exs)E's
mcl_bookclub_admin_testscase for case, throughPhoenix.ConnTestagainst a real reckon-db store and the PRJ projections (ProjectBookclub.TestEnv). The cases: club initiated and read back; member registered with the club's name and read back; reading started and finished, then listed by member; a missing field is a 400; an unknown id is a 404. Added: an unreadable or non-object body is empty params (400, not a crash); a caller's own club name is kept; a route with no desk is a 404. E's static-UI case becomes the LiveView mount test in the next PR.Not in this PR
mcl_om_wire_test, which comes with E's mcl_om 1.6 / macula 18 line), @moduledoc text, CHANGELOG.Checks (msi00, CI image)
At
7ed3ef3: deps, format, compile--warnings-as-errors, credo--strict, dialyzer, all rc 0. mix test: host 186, prj 20, qry 16, fac 11, web 15 (8 new); 0 failures.Mutants (each killed):
Landed by fast-forward: main is
7ed3ef30ba(from26c55732). This repository does not allow the manually-merged style, so the PR is closed by hand.Pull request closed