<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Olufemi Adeojo on Medium]]></title>
        <description><![CDATA[Stories by Olufemi Adeojo on Medium]]></description>
        <link>https://medium.com/@fadeojo?source=rss-f90a459e227f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6cTTekzTbIro-UnMqzR1YQ.jpeg</url>
            <title>Stories by Olufemi Adeojo on Medium</title>
            <link>https://medium.com/@fadeojo?source=rss-f90a459e227f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:21:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fadeojo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setting up HashiCorp Vault (HA) in an AWS environment without Consul]]></title>
            <link>https://medium.com/@fadeojo/setting-up-hashicorp-vault-ha-in-an-aws-environment-without-consul-fd3190fbab19?source=rss-f90a459e227f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd3190fbab19</guid>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[hashicorp-vault]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Olufemi Adeojo]]></dc:creator>
            <pubDate>Tue, 10 Sep 2019 14:29:35 GMT</pubDate>
            <atom:updated>2019-09-10T14:29:35.301Z</atom:updated>
            <content:encoded><![CDATA[<p>I was recently given the task to setting up a Vault cluster for our three deployment environments; latest, staging, production. Vault comes packaged as a <a href="https://www.vaultproject.io/downloads.html">binary</a> but you can also obtain a docker <a href="https://hub.docker.com/_/vault">image</a> depending on your deployment preferences. We didn’t want to maintain a consul cluster so we came up with the setup in this post. This post is for intermediate/advanced AWS users that need a cheatsheet for setting up a HA Vault cluster<strong>.</strong></p><h4>Part 1: Bake AMI for EC2 instances that will run Vault</h4><p>Our tool of choice for building the AMI (Amazon machine image) is <a href="https://www.packer.io/">Packer</a>. Packer uses a JSON file to define the configuration steps to build a custom AMI. You can consult the Packer docs for more detailed explanations of Packer constructs.</p><ul><li>Variables: These are variables that can be passed in and referenced in the JSON config file.</li><li>Provisioners: This section of the config file is responsible for prepping the image and downloading the Vault binary. The vault config file is copied in to the image, a sysvinit file is copied into the image to help with running vault as a linux service. The <a href="https://gist.github.com/fadeojo/658185f41f534b59e6cc5f0f8dc5d1f1">JSON config</a> file below might be a little much so you don’t have to dwell on it to start.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4680f3cf9f135033515f9bee6b3a2d98/href">https://medium.com/media/4680f3cf9f135033515f9bee6b3a2d98/href</a></iframe><p>A <a href="https://gist.github.com/fadeojo/9e821d0103a8d8fdcf01f6b7d040f707">vault.sysvinit</a> and <a href="https://gist.github.com/fadeojo/4100221028add2093045af65fb620b07">create-vault-config.sh</a> file would be required in order to bake the Vault image successfully.</p><p>The Packer image can be baked using the following command;</p><pre>packer build -var &quot;aws_region=us-east-1&quot; -var &quot;source_ami=&lt;your base ami of choice&gt;&quot; vaulti-ami.json</pre><h4>Part 2: Setup CloudFormation template</h4><p>Now that the base image is built, a CloudFormation template will be built so the the process of provisioning Vault is automated. The code snippet below is a CloudFormation template that has all the required AWS resources required to deploy Vault in a highly available configuration. Please read through it and fill in the blanks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/320e68e3c111376e2ed941ec0661d524/href">https://medium.com/media/320e68e3c111376e2ed941ec0661d524/href</a></iframe><p>Running vault without having to manage a Consul cluster has made it easy for us to adopt it. Having a CloudFormation setup has also made it easy to start up new clusters and has made disaster recovery seamless. Our experience with the above setup and vault has been very positive. Please feel free to leave comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd3190fbab19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The curious case of reusable javascript state management]]></title>
            <link>https://medium.com/@fadeojo/the-curious-case-of-reusable-javascript-state-management-25e433a7b05?source=rss-f90a459e227f------2</link>
            <guid isPermaLink="false">https://medium.com/p/25e433a7b05</guid>
            <category><![CDATA[mobx]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Olufemi Adeojo]]></dc:creator>
            <pubDate>Sat, 05 Jan 2019 04:18:46 GMT</pubDate>
            <atom:updated>2019-01-05T04:18:46.391Z</atom:updated>
            <content:encoded><![CDATA[<p>In January of 2018 my team was exploring the possibility of taking advantage of using javascript to target web, mobile and desktop. We already had experience building react applications and wanted to reuse as much of the previous code as possible to build desktop and mobile applications using javascript.</p><p>I remember a meeting where my manager and director shared their vision of what this new world should look like and the theme was “Code Reuse”. How can we reuse as much as possible? I was tasked with researching possible solutions and estimating the cost to the engineering organization.</p><p>I like to make diagrams of my thoughts so I made the following;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xdVowo0y3zkIHFhn15I-gg.png" /><figcaption>Diagram of my thoughts (this is a living document)</figcaption></figure><h4>Code Reuse</h4><p>After days of prototyping, I realized that the “<em>write once deploy to many platforms</em>” approach was not efficient or effective and left me even less confident about the end result of my research. Some technologies worth mentioning are;</p><ul><li>React-native</li><li>React-native-web</li><li>ReactXP</li></ul><p>I started talking to friends in the javascript community to try to learn from what others in my shoes have learned and I also didn’t want to repeat mistakes that could be avoided. The javascript community was tremendously helpful. I posted messages on slack channels, discord channels and more. I bugged as many online and offline friends that would give me their audience. In the end, it was clear that there were two main areas that were worth exploring;</p><ul><li>UI components.</li><li>Application logic.</li></ul><p>I am going to focus on the <strong><em>application logic </em></strong>part of my research from this point on.</p><h4>Application logic</h4><p>Now I know that application logic is a broad term but for the purpose of this post, it represents logic that can be stored in a separate file, to be imported by other parts of our application that can take advantage of it. In our case this would be the bulk of the logic that resides in our state management library of choice. My test environment was made up of a react web app (Web), react electron app (Desktop) and a react native application.</p><h4>Redux</h4><p>We used <strong><em>redux</em></strong> in the past so I tried to create a local stand alone package that held the redux store, actions and reducers. A simple example can be seen in the code below.</p><pre>Import { createStore } from &#39;redux&#39;</pre><pre>/**<br> * This is a reducer, a pure function with (state, action) =&gt; state signature.<br> * It describes how an action transforms the state into the next state.<br> *<br> * The shape of the state is up to you: it can be a primitive, an array, an object,<br> * or even an Immutable.js data structure. The only important part is that you should<br> * not mutate the state object, but return a new object if the state changes.<br> *<br> * In this example, we use a `switch` statement and strings, but you can use a helper that<br> * follows a different convention (such as function maps) if it makes sense for your<br> * project.<br> */<br>function counter(state = 0, action) {<br>  switch (action.type) {<br>    case &#39;INCREMENT&#39;:<br>      return state + 1<br>    case &#39;DECREMENT&#39;:<br>      return state - 1<br>    default:<br>      return state<br>  }<br>}</pre><pre>// Create a Redux store holding the state of your app.<br>// Its API is { subscribe, dispatch, getState }.<br>let store = createStore(counter)</pre><pre>// You can use subscribe() to update the UI in response to state changes.<br>// Normally you&#39;d use a view binding library (e.g. React Redux) rather than subscribe() directly.<br>// However it can also be handy to persist the current state in the localStorage.</pre><pre>store.subscribe(() =&gt; console.log(store.getState()))</pre><pre>// The only way to mutate the internal state is to dispatch an action.<br>// The actions can be serialized, logged or stored and later replayed.<br>store.dispatch({ type: &#39;INCREMENT&#39; })<br>// 1<br>store.dispatch({ type: &#39;INCREMENT&#39; })<br>// 2<br>store.dispatch({ type: &#39;DECREMENT&#39; })<br>// 1</pre><p>I found it interesting that our entire application logic could be decoupled from the UI. After all, we have an initial state of ‘0’ and can dispatch an action to increment our state to ‘1’ and so on. I got all excited and added more logic. I could handle synchronous and asynchronous (api calls) without coupling the global state to any ui. I used <a href="https://quokkajs.com/">Quokka</a> to evaluate state in my text editor.</p><p>The example code above is pure javascript. It can be used in any javascript environment provided the <strong><em>redux </em></strong>package is available. A command line, server-side or client-side app looking to implement a counter could import the above code from a package and use it.</p><h4>Pain</h4><p>When the use case was simple redux was a delight but that started to change as my application grew. I was struggling to keep up with all the boilerplate code and I didn’t know any better so I just powered through it. There had to be a better way to do this I thought as I piled middleware on middleware until…</p><h4><a href="https://github.com/mobxjs/mobx-state-tree">mobx-state-tree</a> (MST)</h4><p><a href="https://medium.com/u/6ca0fe37eac1">Gant Laborde</a> mentioned <a href="https://github.com/mobxjs/mobx-state-tree">mobx-state-tree</a> (MST) while we were discussing state management for React applications. <a href="https://medium.com/u/6ca0fe37eac1">Gant Laborde</a> mentioned that <a href="https://infinite.red/">infinitered</a> was evaluating it for the next iteration of the Ignite boilerplate codenamed “Bowser”. <a href="https://github.com/mobxjs/mobx-state-tree">M</a>ST was built on <a href="https://github.com/mobxjs/mobx">mobx</a> and I had used mobx in the past so I decided to try it out.</p><p>As defined on the github repository, MST is an Opinionated, transactional, MobX powered state container combining the best features of the immutable and mutable world for an optimal DX. There is a free <a href="https://egghead.io/lessons/react-describe-your-application-domain-using-mobx-state-tree-mst-models">egghead tutorial</a> on it, all you need is to provide an email so that an authenticated link of the tutorial can be sent to you. it’s the best way to get started with MST.</p><p>The code below is an example of a counter implemented using MST.</p><pre>import { types } from &quot;mobx-state-tree&quot;</pre><pre>// Create store definition<br>const CounterStore = types.model(&quot;CounterStore&quot;, {</pre><pre>    counter: types.number</pre><pre>}).actions(self =&gt; {</pre><pre>    return {<br>        increment() {</pre><pre>            self.counter ++</pre><pre>        },</pre><pre>        decrement() {</pre><pre>            self.counter --</pre><pre>        }</pre><pre>    }</pre><pre>})</pre><pre><em>// initialize the store<br></em>const counter = CounterStore.create({<br>    counter: 0<br>})</pre><pre>counter.increment()</pre><pre>console.log(counter.counter) <em>// 1</em></pre><pre>counter.increment()</pre><pre>console.log(counter.counter) <em>// 2</em></pre><pre>counter.decrement()</pre><pre>console.log(counter.counter) <em>// 1</em></pre><p>The example code above is also pure javascript. It can be used in any javascript environment provided the <strong><em>MST</em></strong> package is available. A command line, server-side or client-side app looking to implement a counter could import the above code from an npm package and use it.</p><p>Handling large amounts of logic was also very simple as I kept each model in it’s own file. The amount of boilerplate was not as much as redux and features of mobx and MST like observable, actions, views, volatile state, tree structure, patches and flow made it easy to model complex logic.</p><p>we used <a href="https://github.com/lerna/lerna">lerna</a> to create a mono repo that held the ui repository and our app logic repository. This ensured we could import the application state as though it was in the same repository as our ui.</p><p>There were cases where we had a very large initial state and could hydrate our state in a nodejs Lambda and send the reconciled state to the UI so we did very little computation on the browser. This was only possible because our state was a separate package that could be imported into any javascript environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0Lj1ZG0F6qG8dLsKvQ8Ig.png" /><figcaption>Diagram of my thoughts (this is a living document)</figcaption></figure><p>In the end we were able to build a good part of our app logic and test it without a UI. The exercise has changed how I think of application state. Our UX team was busy on another project and this method bought the UX team time to catch up with us. I believe this method would also be great for prototyping. Imagine being able to connect the application logic package with a tool like <a href="https://framer.com/">FramerX</a> or <a href="https://www.invisionapp.com/studio">Invision Studio</a>. The possibilities ………….</p><p>In the end, we chose to share the application logic across all platforms, build the UI for each platform and that was enough!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25e433a7b05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Elixir GraphQl API with Mithril]]></title>
            <link>https://medium.com/@fadeojo/building-an-elixir-graphql-api-with-mithril-fe0f52ceb3d2?source=rss-f90a459e227f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe0f52ceb3d2</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Olufemi Adeojo]]></dc:creator>
            <pubDate>Tue, 09 Oct 2018 20:23:00 GMT</pubDate>
            <atom:updated>2018-10-22T13:36:55.580Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tSH_o-C2Y42368T-" /><figcaption>“Colorful software or web code on a computer monitor” by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Application development requires some plumbing (setup) before building the actual features we intend to ship. This can be a very difficult process and requires experience, especially when trying to adopt a new concept such as GraphQL.</p><p><a href="https://github.com/infinitered/mithril">Mithril</a> is a project generator for phoenix framework based web applications. It promotes conventions that help to build long-lived, maintainable, and highly scalable backend servers.</p><p>I stumbled on this project generator while reading <a href="https://github.com/infinitered">Infinite Red</a>’s GitHub repositories. I noticed that they have a lot of great projects to use and learn from. Take some time to explore their repositories, it will be worth your time.</p><p>Please note that you will need;</p><ol><li>elixir installed on your computer.</li><li>A running Postgresql database</li></ol><p>Let’s get started!</p><ul><li><strong>Install Mithrill</strong></li></ul><pre>$ mix archive.install hex mix_generator<br>$ mix archive.install hex mix_templates<br>$ mix template.install hex mithril</pre><ul><li><strong>Generate a new project.</strong></li></ul><pre>mix gen mithril my_app --accounts --api graphql --ecto postgres --email --websockets --assets --asset-bundler webpack --ci travis --deploy heroku --html eex --sass-syntax scss --gettext</pre><p>This will generate an elixir umbrella project with the following structure;</p><pre>my_app/ <br>├── README.md <br>├── apps <br>│   ├── my_app     # Business logic (&quot;Domains&quot;), persistence <br>│   └── my_app_api # GraphQL API (uses <a href="https://github.com/absinthe-graphql/absinthe">Absinthe</a>)<br>│   └── my_app_web # Phoenix Endpoint <br>├── bin <br>│   ├── reset      # Resets and rebuilds the project <br>│   ├── setup      # Sets up all dependencies <br>│   ├── test       # Runs tests like they would run on CI <br>│   └── update     # Updates the project (for mobile devs) <br>├── config <br>├── mix.exs <br>└── mix.lock</pre><p>Each app has specific, isolated responsibilities.</p><ul><li>my_app A pure Elixir app which handles <strong>logic</strong> and <strong>persistence</strong>, with few dependencies.</li><li>my_app_api [Client] The API for the project. (Usually GraphQL) Calls into my_app’s logic.</li><li>my_app_web [Client] Tiny Phoenix app which mounts the API and calls into my_app’s logic.</li></ul><p>In the project directory,</p><p>run bin/setup</p><p>run mix phx.server and the server is running !!!</p><p><strong>What do you get by using the Mithril generator?</strong></p><ul><li>Fully functioning GraphQL API (impeccable in my opinion)</li><li>Authorization (<a href="https://hexdocs.pm/mithril/authorization.html#content">Docs</a>)</li><li>Email Notification Service using <a href="https://github.com/swoosh/swoosh">Swoosh</a></li><li>Domain-driven design application structure.</li><li><strong>ALL YOU NEED BEFORE ACTUALLY BUILDING YOUR APP</strong></li></ul><p>This is just the beginning of the journey. Read through the code and let it inspire you into greatness. It literally changed how I write code in other languages. The concepts used by Mithril are universal across languages and can be adopted in any server application.</p><p>I would like to thank the <a href="https://github.com/infinitered">InfiniteRed</a> team and <a href="https://github.com/danielberkompas">Daniel Berkompas</a> for the great job they do in and for the open source community. <strong>They inspired my first Medium post.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe0f52ceb3d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>