One of the first projects I like to do when I start learning a new language or a new technology is to find that language's HTTP framework and try to write a simple CRUD (Create, Read, Update, Delete) JSON API. In my view, that's a great starting point, because integrating a database and a HTTP layer is quite simple, but it is not trivial, especially as you start adding concepts like authentication or validation.

This approach, however, has been frustrated slightly in recent years with the wider and wider adoption of automatically generated code in many frameworks. It seems that many creators now prefer to give the user the ability to get to a working application quickly by using command-line tooling to generate various components of the system. This, though, comes at the expense of understanding of how the pieces fit together. Many guides will not offer the write-from-scratch experience anymore, and will just get the user to the quick-start point by using automated code generation.

I found that it was quite tough to find such resources for the premier Elixir HTTP frameworkβ€”Phoenix. Hence, I decided to sit down and write a simple todo-list API without using the built-in JSON endpoint generator, in order to get a bird's eye view of how the pieces fit together. I was guided by the code output by the mix phx.gen.json command, and the resulting code is pretty much the same thing as the code generated by the codegen.

continue reading on intercaetera.com

⚠️ This post links to an external website. ⚠️