<?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 Daniele Fontani on Medium]]></title>
        <description><![CDATA[Stories by Daniele Fontani on Medium]]></description>
        <link>https://medium.com/@daniele-fontani?source=rss-97d01fcd4684------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Qo0EgIXjyw_9Y77YMbc1mg.png</url>
            <title>Stories by Daniele Fontani on Medium</title>
            <link>https://medium.com/@daniele-fontani?source=rss-97d01fcd4684------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:49:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daniele-fontani/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[Unchain Bash Capabilities With a Package Manager]]></title>
            <link>https://levelup.gitconnected.com/unchain-bash-capabilities-with-a-package-manager-f5f6374c8d96?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5f6374c8d96</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Tue, 03 Jan 2023 13:41:10 GMT</pubDate>
            <atom:updated>2023-01-03T13:41:10.362Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to add modernity to a pillar of the development process</h4><p>Undoubtedly, Bash is the most common scripting language used in UNIX systems and is nowadays widely used on Windows too since we have WSL distro shipped with the OS. Despite it being one of the most important pillars of software automation, the scripting experience is very poor. In fact, it doesn&#39;t have a proper IDE and the way we use it for producing scripts is more or less the same as we had for decades. Based on my daily experience, I feel the lack of an efficient argument parsing process (usually we need to write a lot of code for achieving a satisfying result) and the fact that there isn&#39;t any option for sharing script with others that copy/paste or with a git repository. Coming from an experience with multiple languages (.net, PHP, Java, GO, etc.), I feel this lack like a big pain point and this lead me to build the first open-source package manager for Bash scripts.</p><p>In this article, I will explain what is a package manager and how it can solve multiple issues. Moreover, we will discover how to unchain the Bash capabilities pushing it to the next level.</p><p>Let’s start!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*spFnsQBD5kVDA0Ph" /><figcaption>Photo by <a href="https://unsplash.com/@muratodr?utm_source=medium&amp;utm_medium=referral">Murat Onder</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is a package manager?</h3><p>Before all, just a quick deep dive into the package manager definition.</p><blockquote>A package manager is a tool or a suite of tools that manages software or OS dependency</blockquote><p>Where, for “manage” I mean install, update and share and for “dependency” I mean programs, libraries and other kinds of artefacts. A typical implementation of a package manager is described in the next architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iKOwsslnALfLWzU1" /><figcaption>The architecture of a typical package manager. Made with ❤️ form the author</figcaption></figure><p>In the next image we can see a list of the standard package manager for the most used languages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jt2TO43kfR04BnNbIWx4w.png" /><figcaption>Package manager examples. Made with ❤️ from the author</figcaption></figure><p>Now that it’s clear what is a package manager, just see how w</p><h3>How to start using a package manager and unchain Bash capabilities</h3><p>In this section, we will see how to use <a href="https://github.com/zeppaman/bashy">Bashy </a>to simplify the BASH script usage. This tool enhances Bash script to be in compliance with the newest standards, and it saves us tons of hours. In other words, it helps us to increase the quality and delivery of more efficient scripts with the same effort. Bashy is an open-source tool that you can download for free from GitHub (works on any OS).</p><p>Since you have Bashy installed, you can add the script to your repository as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5BhUZ4wzZzJycCmR" /><figcaption>how to add scripts to bashy</figcaption></figure><p>As you can see, each script is described by a YAML file that contains metadata and the script, if this is embedded (can also be separated files). The YAML file you are going to import can be a local file, like when you produce a script on your PC, or it can be a remote URL like when someone shared a script with you.</p><p>In the next picture, there is a sample of a script that lists files in a folder, taking parametric inputs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FsO6v7rkw4lB0YoE" /><figcaption>sample of a bashy script</figcaption></figure><p>Another benefit of using bashy is that provides out-of-the-box argument parsing. As you can see in the previous image, you just have to describe parameters in the manifest and they are automatically available as variables in the script.</p><p>Finally, we can run it as in the next picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*99gpsmrHrTWL9gr_" /><figcaption>how to run bashy</figcaption></figure><p>Now that we have learned all about package managers and Bash, we can jump to the conclusions</p><h3>Conclusions</h3><p>Writing Bash script is still a part of the development process. A lot of scripts, especially in the automation process and DevOps, are based on this scripting language. However, it has some friction due to the lack of an efficient way for parsing arguments and sharing scripts. Using Bash in conjunction with modern tools like Bashy can overcome the limitation of Bash and let us continue using it without headache.</p><p>Now, we can download <a href="https://github.com/zeppaman/bashy">Bashy </a>and stop to face with Bash limitations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5f6374c8d96" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/unchain-bash-capabilities-with-a-package-manager-f5f6374c8d96">Unchain Bash Capabilities With a Package Manager</a> was originally published in <a href="https://levelup.gitconnected.com">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a SaaS Application and Host It on Vercel]]></title>
            <link>https://medium.com/better-programming/host-saas-application-for-free-323a830e762?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/323a830e762</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Wed, 14 Dec 2022 06:19:47 GMT</pubDate>
            <atom:updated>2022-12-14T15:27:04.411Z</atom:updated>
            <content:encoded><![CDATA[<h4>Host, preview, and ship multitenant SaaS applications fast</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T26hJ5DNH2O7ldw2" /><figcaption>Photo by <a href="https://unsplash.com/@helloimnik?utm_source=medium&amp;utm_medium=referral">Hello I&#39;m Nik</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Modern technologies empower our everyday coding experience. A few years ago we needed a lot of competencies for implementing a simple website and hosting it. Still today, a lot of people are convinced that for building and delivering an application we need a multidisciplinary team.</p><p>It is true in many complex scenarios but for a lot of startups and simple projects, the approach we used is radically changed. Thanks to the new technologies, fronted developer or professional that has basic development competencies can create their own app.</p><p>In this article, we will see how to take advantage of cloud technologies for implementing a multitenant application just by using Vue.js and a few lines of configuration. In other words, we will learn how to create a basic SaaS application that can be used by multiple users. Moreover, that solution can be hosted in a Vercel fee tier and start without spending a cent.</p><p>Let’s see how it is possible.</p><h3>The Roadmap</h3><p>In this article, we will cover many points that are important to understand the solution. You can find all the source code related to this example on GitHub (link at the end of the article). The demo application is a notebook that allows users to write notes in the cloud, like in productivity tools such as Evernote or One Note.</p><p>Since it is quite impossible to explain all the source code line by line, I will focus on the most important steps:</p><ol><li>How to implement the backend without being a backend developer</li><li>Implement the frontend</li><li>How to host the application for free</li></ol><p>Let’s start step by step!</p><h3>How to Host the Application for Free</h3><p>This application uses Vercel for hosting both frontend and backend. At the moment I’m writing this article, Vercel has a free tier that host any frontend application (see <a href="https://vercel.com/pricing#plan-compare">price page</a> for seeing limitation).</p><p>The part that was very interesting is the support for serverless functions that, in fact, enable the application to be fully functional. In the free tier, we have 100 GB-hours limits (product of RAM used for each request multiplied by the time) but it can be overcome by buying a paid plan.</p><p>Vercel connects directly to your git repository, builds the source code and publishes it. If you want to discover more you can read the article “<a href="https://medium.com/better-programming/how-to-deploy-an-existing-application-with-vercel-cfcd314e5396"><em>Deploying an application with Vercel</em></a>”.</p><p>Since all we need to know was already told in the article mentioned above, I will explain only the most important steps.</p><ol><li>First of all, you have to create a project on Vercel. After you do that, you will see the next screen:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XgcbL8wxpmq2-FosZyN4g.png" /><figcaption>After creating a project.</figcaption></figure><p>2. You have to click “Connect” and choose your git repository. See the following image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*yPEvTHnI4jmRM5H3YrDtwQ.png" /><figcaption>choosing the right git repository</figcaption></figure><p>3. At the next push to the main branch, the application will be published. After that, you will see the project status, link and details in the project panel, like in the following picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uDg1j_HUu_iE9CHCiKRUFg.png" /><figcaption>project panel in Vercel</figcaption></figure><p>Now that we found a solution for hosting, let’s see how to implement the backend.</p><h3>How to Implement the Backend Without Being a Backend Developer</h3><p>One of the most critical parts is the specialization of developers. A lot of front-end developer has great ideas, but when start to implement it discover that it’s hard to do something without a strong backend experience.</p><p>Most of the time this gap can be filled by adopting headless low-code platforms like <a href="https://medium.com/u/ace2e82e28e6">Strapi</a> or <a href="https://medium.com/u/5a131a53c7b2">Contentful</a> but in some cases could be an unwanted dependency.</p><p>In this example, I will show you to get a good compromise by adopting CrudIt a lightweight library that wraps a database by APIs. In poor words, it means that we have the opportunity of accessing all data using REST APIs. Moreover, <a href="https://github.com/zeppaman/crudit">CrudIt </a>supports a natively multitenant environment with a <em>db-per-user</em> policy. That’s all that we need!</p><p>In the next steps, I will describe how to integrate it.</p><ol><li>Run npm install --save crudit . This command will install the package in your project.</li><li>Create a file called handler.mjs in apifolder. The path in our local will be api/handlre.mjs and the URL on Vercel will be <a href="http://yourpath/api/handler">http://yourpath.vercel.io/api/handler</a></li><li>Add to the handler.mjs following code:</li></ol><pre>import {crudy,database} from &#39;crudit&#39; ;<br>import {IncomingMessage, ServerResponse} from &#39;http&#39;<br>import crypto from &#39;crypto&#39;<br><br><br> crudy.config(function(config){<br>  config.settings.roles=[&#39;owner&#39;];<br>});<br><br>export default async function handler(request, response) {  <br>  return await crudy.run(request,response);<br>}</pre><p>With this code, you have yet a rest endpoint that let you explore data automatically. For example, you can list all data from the notes collection by invoking a GET request on <a href="http://yourpath/api/handler">http://yourpath.vercel.io/api/handler</a>?collection=notes .</p><p>As per the REST standard, you can make a post to insert a new row, patch to update only a few fields and so on. That’s great, but what about security? Let’s see in the next section</p><h3>Multitenancy in CrudIt</h3><p><a href="https://github.com/zeppaman/crudit">CrudIt</a> implements its authorization mechanism based on user and user roles where you can specify, entity per entity, which data can see a user. In this example, we want to create a database for each user and let him see all the contents that own.</p><p>For doing this the first step is to implement the authenticate method. Assuming we have a collection that stores users and user tokens, we have something like this:</p><pre>crudy.authorize(async function(request){<br>let token=request.headers.authorization ?? request.query.authorization;<br>let users=await database.aggregate(&#39;global&#39;,&#39;users&#39;,[{<br>    $lookup:<br>    {<br>        from: &#39;tokens&#39;,<br>        localField: &#39;_id&#39;,<br>        foreignField: &#39;userId&#39;,<br>        as: &#39;token&#39;,<br>    },<br>    <br>}, {<br>    &quot;$match&quot;: {<br>        &quot;token.token&quot;: token<br>    }<br>    }]);<br>if(users==null || users.length!=1) return  null;<br>let user=users[0];<br>return {<br>    name:user.name,<br>    roles:[&#39;owner&#39;],<br>    database:user.db<br>};<br><br>});</pre><p>In the snippet above, the query takes the authentication token from the request, uses it for fetching data from the database (the query gets the user related to the token), and returns an object containing user data. This object is used by the CrudiIt engine to allow the user to access data or not. Of course, you can replace this code to support any JWT or Oauth2 tokens, but also old-style cookie-based or BasicAuth login.</p><p>But how to implement the login and registration endpoint? To do this you can implement an endpoint. Instead of creating a new handler for Vercel you can register an endpoint into the CrudIt engine. This has also the advantage of being portable because it doesn&#39;t change by the server (it’s the same on Vercel, express or any other Node.js servers). The registration endpoint can be something like this:</p><pre>crudy.request(&quot;register&quot;, &quot;post&quot;,false,async function(request,loggedUser, settings){<br>    let user=request.body;<br>    user.password= crypto.createHash(&#39;md5&#39;).update(user.password).digest(&#39;hex&#39;);<br>    //Create a unique and valid db name escaping the username<br>    user.db=(&quot;c_&quot;+user.username??&#39;sdff&#39;).normalize(&#39;NFD&#39;)<br>            .replace(/[\u0300-\u036f]/g, &#39;&#39;)<br>            .toLowerCase()<br>            .trim()<br>            .replace(/[^a-z0-9 ]/g, &#39;&#39;)<br>            .replace(/\s+/g, &#39;-&#39;);<br>    //save it<br>    user= await database.insert(&quot;global&quot;,&quot;users&quot;,user); <br>    return user;<br>});</pre><p>The previous snippet binds the function to the POST method and to the register action, so you will be able to call it by:</p><pre>curl --location --request POST &#39;http://localhost:3000/api/handler?action=register&#39; \<br>--header &#39;Content-Type: application/json&#39; \<br>--data-raw &#39;{<br>    &quot;password&quot;:&quot;mypass&quot;,<br>    &quot;username&quot;:&quot;testuser&quot;,<br>    &quot;name&quot;:&quot;My Name&quot;,<br>}&#39;</pre><p>Now we have an endpoint that creates a new user hashing the password, we can implement the login one as follows:</p><pre>crudy.request(&quot;login&quot;, &quot;post&quot;,false,async function(request,loggedUser, settings){<br>    database.init(process.env.DBURL, {});<br>    let hash= crypto.createHash(&#39;md5&#39;).update(request.body.password).digest(&#39;hex&#39;);<br>    let user= await database.search(&quot;global&quot;,&quot;users&quot;,{username:request.body.username, password:hash});<br>    if(!user || user.length!=1) throw new Error(&quot;Wrong username and password&quot;);<br>    user=user[0];<br>    let newToken= crypto.randomBytes(64).toString(&#39;hex&#39;);<br>    let token={userId: user._id,token: newToken};<br>    token=await database.insert(&quot;global&quot;,&quot;tokens&quot;,token);  <br>    return {token: newToken};<br>  });</pre><p>The script above validates username and password and if the data are correct, it creates a token and returns it to the user. This token will be passed into the authentication headers and validated by the authentication method.</p><h4>Details matters: multitenancy with ease</h4><p>In the previous section, we see how the user is able to invoke APIs for registering and logging in. By the way, there is a small detail that makes it possible to implement a multitenant system. During the registration phase, a database name is assigned to the user:</p><pre>//...<br>user.db=(&quot;c_&quot;+user.username??&#39;sdff&#39;)//userneame is used as database name<br>//...<br>return {<br>    name:user.name,<br>    roles:[&#39;owner&#39;],<br>    database:user.db<br>};</pre><p>Then, into the authenticate phase this information is used to define in with database the CRUD operation must be done. This, in conjunction with the fact that <a href="https://medium.com/u/db5cd12199bd">MongoDB</a> is able to create a collection and database when the data is added, makes it possible to create a fully multitenant environment with a few lines of code!</p><p>If you are not satisfied, we can go deeper and see how to use the backend to create a real SPA application in Vue.Js! Just start reading the next section.</p><h3>Implement the Frontend</h3><p>In this example, I used a Vue.js application that uses Vuetify, a framework that implements Material Design patterns. It is not possible to discuss all details, so I will focus only on the most relevant parts:</p><ol><li>create a service layer for connecting to the backend</li><li>authenticate request automatically</li><li>implement login/register forms</li><li>implement the notes feature</li></ol><p>The first step is to add some common methods into all the components for interacting with the backend engine. In this case, I create a MixIn, that in Vue includes automatically the methods to all components. This feature is done by the next piece of code:</p><pre>Vue.mixin({<br>    methods: {<br>      insertOrUpdate: async function(entity, data) {<br>        //omitted for brevity<br>      },<br>      patch:  async function (entity, data){<br>        delete data._meta;<br>        return  this.simplifyResponse(  await this.apiCall(url,&#39;PATCH&#39;,data,{collection: entity}));<br>  <br>      },<br>      remove:  async function (entity, data){<br>        //omitted<br>      },<br>      get:  async function (entity, id){<br>        //omitted <br>      },<br>      search:  async function (entity, filter, projection){<br>        return  this.simplifyResponse(await this.apiCall(url,&#39;GET&#39;,null,<br>         {collection: entity, <br>          query: JSON.stringify(filter)??&#39;{}&#39;,<br>          projection: JSON.stringify(projection)??&#39;{}&#39;<br>        }));<br>      },<br>    },<br>  });</pre><p>Each method wraps an HTTP call to the API endpoint and we have all the CRUD operations ready.</p><p>Now that we can operate on the database we can take care of authentication. This can be achieved globally by adding an Axios HTTP interceptor. Using the next piece of code, if you get a 401 (not logged or unauthorized) you will be redirected to the login page. Moreover, when the user is logged in, the user token is added automatically to the requests.</p><pre>axios.interceptors.request.use(request =&gt; {<br>  let userToken=localStorage.getItem(&#39;userToken&#39;);<br>  if (userToken) {<br>      request.headers.Authorization = `${userToken}`;<br>  }<br>  return request;<br>});<br><br>axios.interceptors.response.use(function (response) {<br>  return response;<br>}, function (error) {<br>  if (error.response &amp;&amp; 401 === error.response.status) {<br>    document.location.href=&quot;/#/login&quot;;<br>  } else {<br>        return Promise.reject(error);<br>    }});</pre><p>Now we can implement a login form and registration form. Both of them are simple Vue components so I will report here only the log-in one (you can find all the source code on GitHub). The template I used is the following</p><pre>&lt;v-container&gt;<br>    &lt;v-row class=&quot;text-center&quot;&gt;<br>      &lt;v-col&gt;<br>       &lt;h1&gt;login&lt;/h1&gt;<br>       &lt;v-form&gt;<br>        &lt;v-text-field v-model=&quot;username&quot; type=&quot;text&quot; label=&quot;login&quot; /&gt;<br>        &lt;v-text-field v-model=&quot;password&quot; type=&quot;password&quot; label=&quot;Password&quot;/&gt;<br>        &lt;v-btn @click=&quot;save&quot; block &gt;Save&lt;/v-btn&gt;<br>       &lt;/v-form&gt;<br>      &lt;/v-col&gt;<br>    &lt;/v-row&gt;<br><br>    &lt;v-row class=&quot;text-center&quot;&gt;<br>      &lt;v-col&gt;<br>       &lt;v-subheader&gt; Not an user? &lt;a href=&quot;#&quot; @click=&quot;$router.push({name:&#39;register&#39;})&quot;&gt;Register&lt;/a&gt;&lt;/v-subheader&gt;<br>      &lt;/v-col&gt;<br>    &lt;/v-row&gt;<br>  &lt;/v-container&gt;</pre><p>And the javascript part is described by the next javascript:</p><pre>export default {<br>    name: &#39;Login&#39;,<br>    beforeMount:async function(){<br>       <br>    },<br>    methods:{<br>        save: async function(data){<br>            let response=await this.apiCall(&#39;/api/handler&#39;,&#39;POST&#39;,{username:this.username, password:this.password},{ action:&quot;login&quot;});<br>            <br>            if(response.status !=200 || response.data.hasError)<br>            {<br>              this.showError(&quot;login failed&quot;);<br>            }<br>            else<br>            { <br>              let user=response.data.data;<br>              this.showSuccess(&quot;Hello &quot;+user.name);<br>              localStorage.setItem(&#39;userToken&#39;,user.token);<br>              this.$router.push({name:&#39;notes&#39;});<br>            }<br>        }<br>    },<br>     data: () =&gt; ({<br>      token:&quot;&quot;,<br>      username:&quot;&quot;,<br>      password:&quot;&quot;,<br>      })<br>  }</pre><p>Finally, we can implement our application using the backend that’s already in place!</p><h3>Conclusion</h3><p>Thanks to modern technologies it is no more required to be a specialist to create a multitenant application and thanks to cloud services, hosting is no longer painful.</p><p>Of course, when the requirements of the application become challenging we will need to face complexity (the cost of the cloud will become relevant, and you will still need more than one member on the team).</p><p>However, for a simple project, MVP or startup having an easy way to start it’s very important. As quickly as the project becomes more demanding we will have to scale the application in sustainable growth.</p><p>References:</p><ul><li>The CrudIt framework is available on GitHub and delivered by NPM. See the project page for more info <a href="https://github.com/zeppaman/crudit">https://github.com/zeppaman/crudit</a></li><li>You can learn more about <a href="https://vercel.com/">Vercel</a> on the official website</li><li>You can download the source code of this example <a href="https://github.com/zeppaman/crudit-demo">here</a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=323a830e762" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/host-saas-application-for-free-323a830e762">How to Create a SaaS Application and Host It on Vercel</a> was originally published in <a href="https://betterprogramming.pub">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I tried to revolutionize the scripting experience]]></title>
            <link>https://medium.com/data-science/better-bash-scripts-ae542fa37bd6?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae542fa37bd6</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 15:33:28 GMT</pubDate>
            <atom:updated>2022-12-05T15:33:28.805Z</atom:updated>
            <content:encoded><![CDATA[<h4>The story behind Bashy the script manager for Bash scripts</h4><p>In this article, I will introduce the Opensource project Bashy, a tool that enhances the scripting experience by facilitating argument parsing and making it possible to share scripts as every package manager does. In another word, I made work Bash as any modern scripting framework should. This can be a boost for improving productivity and automating recurring tasks for programmers and data scientists.</p><p>I will explain why we need a tool like Bashy, and then show how it can be used with some practical examples. Finally, after we will have discovered how it can save hundreds of hours for developers, I will move into the internal components to explain how it works.</p><p>Let’s jump into the article!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ONwDmZqxxyepvv9ESq-mng.png" /><figcaption>Made with ❤️by the author.</figcaption></figure><h3>Why do we need Bashy?</h3><p>The aim of Bashy is to reduce the friction in scripting. The most common issues are:</p><ul><li>parsing input and providing a help page for the script that we created. This is usually messy and requires a lot of time, so this phase is often skipped and we have scripts that are hard to run. Often, developers need to open them and change the variable inside the script itself.</li><li>Sharing scripts. The most common way to share scripts is to copy/paste files from one PC or server to another. This practice is very old style and it’s hard to update scripts as one of the copy changes.</li></ul><p>Bashy is willing to overcome all that problems by implementing:</p><ul><li>a package manager for Bash</li><li>an easy way for parsing arguments.</li></ul><h4>Friction using bash scripts</h4><p>Bash scripts solve a lot of problems but in most cases:</p><ol><li>resides on the PCs of their authors: sharing them is very hard</li><li>are not parametric: parameters are inside the script and the author changes them directly instead of parsing the arguments</li></ol><p>Why? Nowadays this behaviour seems very odd, but if you look at what are the options it’s clear that a developer has no option. In fact:</p><ol><li>there isn’t any repository where pushing your script for sharing</li><li>make the script parametric and requires tons of code</li></ol><p>That’s why I create Bashy:</p><blockquote><em>THE PURPOSE OF BASHY IS TO OVERCOME THIS LIMITATIONS</em></blockquote><p>Now that we understood why it was important to create a tool for managing bash scripts, let’s see how it works in practice!</p><h3><strong>Presenting Bashy starting from results</strong></h3><p>Instead of talking a lot about Bashy, I prefer to explain it by an example. Let&#39;s suppose to create a bash script that lists the file in a folder. The given parameters are the path of the folder and the extension to use for filtering files.</p><p>Well, for implementing it in bash parsing arguments you will have something like this in the following snippet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wQ5uUwzwS0_I_jXg" /><figcaption>Traditional bash script</figcaption></figure><p>Note that in the previous script only the last two lines of code are needed for implementing the script, all the 34 lines above are required only for parsing argument. Moreover, you do not have any help page and adding a new parameter will complicate things. How Bashy can make it better?</p><p>Using Bashy, you will have to write only the following code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*D3t-8ua6o_kvWC0d" /></figure><p>As you see, you have the parameters parsed for free and some variables yet populated that are ready to use. This translates into a huge simplification and, as you see it later, you have also a help page available without any additional effort.</p><p>That’s magic? Let’s see in the next section how it is possible.</p><h3>How it is possible?</h3><p>As information is a science, there isn’t any incantation or magic wand behind the hood. The pillar of Bashy is to describe the script by adding a manifest in YAML format. The YAML and the script together make a package that can be portable and contains all that is required by Bashy to be required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-zost6A518UjPkdS" /><figcaption>How Bashy packages are made. Made with ❤️by the author</figcaption></figure><p>An example of the previous script can be the following snippet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qW20IgohrFetw_j_" /><figcaption>script fore reading folder in bashy. Made with ❤️by the author.</figcaption></figure><p>The YAML manifest contains all the information to be displayed on the help pages and the script to be executed (can be embedded like in this case or a reference to an external resource). Moreover, you define the parameter list that is used by the argument parsing engine.</p><p>This information is used to create a help page like in the following example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_Beat2tnbSNXRX5L" /><figcaption>example of command help. Made with ❤️by the author.</figcaption></figure><p>As you see, the command is registered from Bashy as a global command and you can write it directly as it was a real binary installed on the OS.</p><p>The script made with this technology can be easily shared (you just need to publish on every HTTP server, git included) and helps to build more usable scripts.</p><p>But how it is implemented? The Bashy engine is built using Go and is available as an open-source application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H8lJXw0enYZ2CyIN7Z5d0A.png" /><figcaption>How bashy was made. Made with ❤️ by the author</figcaption></figure><p>The next figure shows the main flows of the application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIQG6HTPDn49_MV77EfL7g.png" /><figcaption>Main flows of the application,Made with ❤️ by the author</figcaption></figure><p>Basically, the Bashy engine adds the information contained in the YAML file into an internal database (red flow). Since you have the information, you can easily list all the commands available and provide help pages (blue flow). Finally, Bashy can execute commands by parsing arguments and passing values as variables to the script you aim to run. The output is then shown to the user.</p><p>To discover more about bashy you can:</p><ul><li>Read the tutorial “<a href="https://medium.com/better-programming/effective-bash-scripts-108d976026bc">The Effective Way To Write Bash Scripts</a>”, or</li><li>Read the article where I explain step by step how Bashy is made “<a href="https://medium.com/better-programming/effective-bash-scripts-108d976026bc">How I created a script engine in GO</a>”</li></ul><p>By the way, I think that Bashy’s potential has not been fully realised. In the next section, I will explain what can be the next feature to add to make it smoother.</p><h3>Next steps</h3><p>Like every product, also open-source applications must look at the market and at the user&#39;s needs. Starting from this, you can get a list of features to add to the backlog. From my experience and from the feedback I got so far, there is a set of improvements that could be very useful. I summarize them in the next picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0zHRBhRZoJXU5IqSpDFueA.png" /><figcaption>next steps of bashy. Made with ❤️by the autor</figcaption></figure><p>So, citing Eric Reis, author of Lean Startup:</p><blockquote><strong>WE MUST LEARN WHAT CUSTOMERS REALLY WANT, NOT WHAT THEY SAY THEY WANT OR WHAT WE THINK THEY SHOULD WANT.</strong></blockquote><p>This pushes me to hear the feedback of users for giving the right priority to these tasks.</p><p>Basically, the most wanted feature is to add a public repository where to add scripts allow users to search them by a web UI and install them locally. Moreover, a smother installation process is also welcome as better documentation on the website.</p><p>Anyway, any feedback is welcome and part of the improvement process! So, if you are a <a href="https://github.com/zeppaman/bashy"><em>Bashy </em></a>user or you are planning to test it, don’t forget to give me feedback 😃</p><h3>Conclusions</h3><p>Bash is a technology widely used but with some friction that makes it hard to implement reusable scripts. Bashy was born to overcome these issues and unleash the power of bash. As with every product, also open-source project needs to listen to the user&#39;s need so it’s important to give feedback to the authors (this is true in general, not only for Bashy). I hope to have given you an opportunity for improving your script experience, don’t hesitate to write your feedback in the comments 😄</p><h4>References:</h4><ul><li>GitHub repository <a href="https://github.com/zeppaman/bashy"><strong>https://github.com/zeppaman/bashy</strong></a></li><li>Tutorial for Bashy “<a href="https://medium.com/better-programming/effective-bash-scripts-108d976026bc">The Effective Way To Write Bash Scripts</a>”</li><li>Technical deep dive into program internals “<a href="https://medium.com/better-programming/effective-bash-scripts-108d976026bc">How I created a script engine in GO</a>”</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae542fa37bd6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/better-bash-scripts-ae542fa37bd6">How I tried to revolutionize the scripting experience</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy an Existing Application With Vercel]]></title>
            <link>https://medium.com/better-programming/how-to-deploy-an-existing-application-with-vercel-cfcd314e5396?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfcd314e5396</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Tue, 29 Nov 2022 13:20:45 GMT</pubDate>
            <atom:updated>2022-11-29T13:20:45.606Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fast, affordable, and simple</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BEZlYbAoKFQTuBRn" /><figcaption>Photo by <a href="https://unsplash.com/@jridley1?utm_source=medium&amp;utm_medium=referral">Jonathan Ridley</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the last years, we moved from professionals that were skilled in many competencies (full-stack) to focused developers. The limitation of the scope leads to more and more efficient people.</p><p>Anyway, while in the past a full-stack was able to build a full project, nowadays a frontend or backend developer finds it difficult to cover all the stack. This is not a real issue in enterprise projects because you have usually a multidisciplinary team where you have all the competencies that you need.</p><p>But what for small companies like startups or personal projects?</p><p>Well, fortunately, the cloud and new technologies help us. Modern tools offer the opportunity to host and deploy your application with a few configuration clicks, keeping the process smooth and cutting learning time.</p><p>In this article, we will learn how to address all these issues with <a href="https://vercel.com/">Vercel</a>, a simple and easy-to-use platform that’s suitable for any frontend technologies and supports also serverless functions for implementing the APIs that you need for making your SPA work. This is the roadmap:</p><ol><li>What is Vercel</li><li>Create the project on Vercel</li><li>Fix your project and test it in your local</li></ol><p>Let start!</p><h3>What is Vercel</h3><p>Vercel is a cloud platform designed for frontend developers that enable developers to host websites and apps that deploy instantly, scale automatically, and require no human effort for maintenance. Vercel has also a free tier that let you start without any costs and offers the opportunity of deploying serverless functions for implementing your backend (included in the free tier).</p><p>Other advantages of using Vercel:</p><ul><li>one-click deployment from any GitHub repository (public or private)</li><li>a free tier with the built-in option to host a backend</li><li>custom domain names available in the free tier</li><li>DevOps included: each push into your repo starts the build process and deploys the app automatically</li><li>Marketplace to integrate third-party services (like database, or SMTP services)</li></ul><p>Cool, not? Let’s see how to deploy an application on it.</p><h3>Create the project on Vercel</h3><p>First of all, you have to create an account. Then, if you start a project from scratch, Vercel itself can initiate a repository using one of the templates on its catalogue. However, it is quite common to be in a situation where you already have a project and you want to deploy it on Vercel. No problem: we will see the process in this article.</p><p>The next step is to create a project. In my case, I used the name crudit-demo because this is the public demo of <a href="https://www.npmjs.com/package/crudit">CrudIt</a>, my Nodejs framework for implementing the backend without being a backend developer.</p><p>Once you create a project, you will see a page like this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XgcbL8wxpmq2-FosZyN4g.png" /><figcaption>project before connecting the repo</figcaption></figure><p>As told in the image before, you need to connect your repo before starting the deployment. This is quite easy: just click the “Connect Git Repository” button. You will be asked to give permission to see your repositories (you can allow them one by one or at all), and then you will see something like this in the following picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*yPEvTHnI4jmRM5H3YrDtwQ.png" /><figcaption>choosing repository</figcaption></figure><p>As you can see from the previous picture, Vercel understands the project type (see the Vue icon near the project name) and you have only to click connect. Then you will see the deploying and when done you will have something like in the following screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uDg1j_HUu_iE9CHCiKRUFg.png" /><figcaption>Vercel deployed</figcaption></figure><p>Your website or app is now online and can be visited! Anyway, most applications need a few additional configuration steps that we will see in the next section. Moreover, it is not told that your application is 100% compatible with Vercel deployments: in this case, you can debug it in your locally using the Vercel cli. We will see also this in the next sections.</p><h4>Vercel panel overview</h4><p>In this section, I will show a set of common sections of the admin panel that you may need to know.</p><p><strong>Deployments</strong></p><p>In this section, you will see the history of all the deployments that you have done. One by one, you can read the compilation log and see the status (each deployment is related to the source code that originates it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44bLgA_e_xOwjZ62KOT2wg.png" /><figcaption>deployment section</figcaption></figure><p>If you click on the deployment section, you will land on a page showing the building details. Moreover, as you can see from the next image, you can see the list of URLs connected with the app. Each deployment has its own URL and in addition, you can add how many custom domains you want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VnuxfiyDG-Mlh3YK5SyMAw.png" /><figcaption>building details</figcaption></figure><p>The list of domains can be changed by the “Domains” section. In my case, I have the default one which is a third-level domain under vercel.app the name of the project. Domain with the deployment name and the git repo name is added automatically (see the one marked as “automatic URL” in the previous image).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*445kLZLVK12eDxrXAsTGBA.png" /><figcaption>domain list</figcaption></figure><p>If you have multiple branches you can define what is the branch that originates new deployment in your app. See this configuration in the next picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*NRN5xPA3UDNHBz1mIOffgA.png" /><figcaption>branch choice</figcaption></figure><p>At the beginning of the article I talked about the serverless function: well, you can choose the location where they are running for accomplishing legislative needs such as GDPR or nearest to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*8tdSHqpatM7NUhFCFs2kiQ.png" /><figcaption>Chose function location</figcaption></figure><p>Finally, most applications need different settings based on environments for the compilation process and at runtime. It can be some parameters about the API&#39;s backend for the frontend SPA, or the database connection string for the function. Vercel support variables natively: you have to enter it like in the next picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*g_qlSNwx24FZxpjR_-ezEQ.png" /><figcaption>adding environment variables</figcaption></figure><p>In the previous image, we have a DBURL variable with a value MYURL that is valid for all environments. In case you have a ready-to-go .env file, you can import it.</p><p>Of course, you can edit these values at any time by clicking on the pencil. You will see something like this in the following picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*TD-a869ZC3W1Am6944YvcA.png" /><figcaption>changing environment variable</figcaption></figure><p>Well, now that everything about the configuration is clear, let’s see how to configure the project in your locally!</p><h3>Fix your project and test it in your local</h3><p>Vercel offers a cli that connects with your cloud account and emulates the working behaviour that you will have in the cloud. To do this, start by downloading and installing the cli:</p><pre>npm i -g vercel</pre><p>Now we can move into the project folder and run:</p><pre>vercel dev</pre><p>The command is an interactive process and requires login. At first execution, you will be asked to link your local folder to a remote project with a prompt like an image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*seSZVoW-EDDhtKRcO-VFMw.png" /><figcaption>starting project</figcaption></figure><p>Then you have to select your project scope and finally, you can enter the project name to link with the one previously created from UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*3BLrmI-rLzLBJuN-w-NgPw.png" /><figcaption>Project connection</figcaption></figure><p>As the last step, we can create the .env file based on the configuration we had for development environments. This can be done by typing:</p><pre>vercel env pull dev</pre><p>The result is the creation of a .env file confirmed by this message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*-rJDLanR7WPJAnHXCdkxlg.png" /><figcaption>environment creation</figcaption></figure><p>Now you are ready to run your application locally and start debugging!</p><h3>Wrap-up</h3><p>In this article, we discovered what is Vercerl and how it helps us make the deployment process smooth.</p><p>Moreover, we had now an opportunity of hosting our application at affordable costs.</p><p>The Vercel adoption is really easy and can be applied also to an existing project, this tutorial is the proof.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfcd314e5396" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-deploy-an-existing-application-with-vercel-cfcd314e5396">How to Deploy an Existing Application With Vercel</a> was originally published in <a href="https://betterprogramming.pub">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Created a Script Engine With Go]]></title>
            <link>https://medium.com/better-programming/bash-argument-parsing-e4bf28b39956?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4bf28b39956</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 17:00:41 GMT</pubDate>
            <atom:updated>2022-11-24T12:45:45.761Z</atom:updated>
            <content:encoded><![CDATA[<h4>Meet Bashy — my open-source tool for packaging Bash scripts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sLhJRFrlStePNrh_" /><figcaption>Photo by <a href="https://unsplash.com/@kasparseglitis?utm_source=medium&amp;utm_medium=referral">Kaspars Eglitis</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Every project starts from a need or an idea. In my case, I was moved by the complexity of parsing arguments in bash scripts and sharing the scripts themself. Most developers that write bash scripts keep them in their local PC and, when needed, copy/paste the file and change the content before running it. Why?</p><p>In a world where each language has its own package manager, and each tool has the help command for describing arguments, that behaviour seems very outdated. Anyway, if you look at the opportunities, you will agree with me that there aren’t many options. Bash script hasn’t any package manager, and there isn’t any standard library for argument parsing (you can find many scripts, but without a package manager, it’s hard to use them).</p><p>I wrote this quick introduction to explain why I created Bashy, the open-source tool that overcame that problem. This article will focus on the most important parts of the application I created. I think there are many interesting ideas that you can reuse in your Go application.</p><h3>What Are the Benefits of Bashy?</h3><p>You can write a YAML file containing the metadata of the script and the script itself (can be embedded or kept externally), like in the following snippets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LThUUV6Q_cfkeqRy" /><figcaption>A bashy script</figcaption></figure><p>In the YAML manifest, you explain the command name and description and the parameter. As you see, the parameters can be used directly in the script as regular variables.</p><p>Finally, you can run the script as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cjRnoaNvlvxbGrxD" /><figcaption>Running the bashy script</figcaption></figure><p>As you can see, the complexity of parsing arguments is removed, and you now have self-contained files (package) that you can share with others. Nice, no? In the next chapter, we will see how the architecture of <a href="https://github.com/zeppaman/bashy">Bashy </a>before drilling down into technical details.</p><h3>How Bashy Works in General</h3><p>The next picture shows how Bashy works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIQG6HTPDn49_MV77EfL7g.png" /><figcaption>the architecture of Bashy. Made with ❤️ from the author</figcaption></figure><p>In the previous diagram, we can see three main flows:</p><ul><li>Add repo (the red flow): the user adds a repository of scripts to the local database (you can download scripts from the internet or add files from your PC). After this step, your database contains all data for the script and can run them.</li><li>Helps (the blue flow): The user can interact with the Bashy script to list all commands registered from the repositories.</li><li>Execute (the green flow): Now that the internal database contains all the info about the script to be run, Bashy can parse the argument and pass it to the script. This step is fully transparent to the user.</li></ul><p>Now we understand the main processes of Bashy. We can go into this case study&#39;s more relevant and interesting part. In my opinion, these parts are:</p><ol><li>Parsing argument engine</li><li>Interpreters engine</li><li>Register command globally</li></ol><p>Just jump into the next section!</p><h3>Parsing Argument Engine</h3><p>The parsing argument is one of the most critical points in the Bash script management and the core of this application, so it deserves the most attention. Anyway, the principle is very simple. I use <a href="https://github.com/urfave/cli">urfave/cli</a>, a console parsing library that lets me parse arguments by explaining the command structure. Each command has a related function that takes the parsed inputs and does things. Sample usage of this library is in the following snippets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACjTmAglcAr3Ba1rvKkvoA.png" /><figcaption>An example of urfave/cli</figcaption></figure><p>In the previous example, there is a flag called lang with a default value of english that can be used inside the function by typing cCtx.String(&quot;lang&quot;). Bashy does the same but reads the list of commands and parameters from the internal database. The implementation is shown in the following snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddd3a225a02f64ee2bf906aa7d9a7f29/href">https://medium.com/media/ddd3a225a02f64ee2bf906aa7d9a7f29/href</a></iframe><p>The action that process all request is implemented by the following piece of code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e91551d31677195dd9bed83593326d2/href">https://medium.com/media/2e91551d31677195dd9bed83593326d2/href</a></iframe><p>Basically, all the script lines get concatenated. Bashy appends the command embedded into the YAML file with an eventual external script, then creates a key/value map with params and invokes the ExecuteCommand utility method that adds the variable definition on top of the script and runs the script itself.</p><h3>Interpreters Engine</h3><p>After I ran Bashy, I realized that it could run any script, not only bash ones. So, the next step was to add the opportunity to define any other script interpreter to allow any user to manage their scripts with bashy regardless of the programming language he is using. The definition of an interpreter is a simple YAML file. In the next snippet, you can see the definition for the Nodejs engine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eSZABIPEG_ySxYrDpSGIRQ.png" /><figcaption>The interpreter definition</figcaption></figure><p>The YAML files contain two interpreters divided by the --- sign. You can see that they are very similar: both are the definition of Nodejs interpreter, but one for windows and one for Linux. This is because you can have different installation steps based on the OS or availability (for example, you cannot have a pure bash in windows or windows console in Linux).</p><p>The anatomy of an interpreter is very easy. You have the following:</p><ul><li>name: the name of the interpreter. In your YAML script, you can explain what interpreter uses it</li><li>variabletemplate: how a variable is defined. For example, in bash, you have VARIABLE=VALUE but in JavaScript var variable=VALUE; $name and $variable are placeholders for parameter names taken from the script definition and the actual value at execution time.</li><li>installscript: these are the script lines used for installing the interpreter. For example, for Ubuntu, we have apt install nodejs -y . For supporting all Linux distributions, I use the trick of adding multiple lines, one for each package manager that is activated by the presence of the package manager itself. This translated into replicating this pattern [[$command -v packagemanagername ]] || {packcagemanager args}.</li></ul><p>Now we have seen how to create and register an interpreter. It remains only to show you how I defined command aliases to make it possible to register your command globally.</p><h3>Register Command Globally</h3><p>Any modern package manager has a command with a “global” option that registers an executable globally. Bashy does the same. You can invoke your script by typing bashy your_script args or directly your_script args . But how is it possible? I use the following trick:</p><ol><li>During instasllation, I add to the $PATH variable a bin folder inside the BASHY_HOME (usually /home/username/.bashy/bin ).</li><li>Whenever you import a script into Bashy, I create a file into the bin folder with the same name as the command. So, this file is visible to the shell and can be run by the user</li><li>The content of the script is a regular sh script (or cmd script on windows) that wraps a bashy invocation with something like:</li></ol><pre>bashy {script name} &quot;@$@&quot;.</pre><h3>Conclusion</h3><p>In this article, we deep-dived into the core feature of Bashy and discovered how they are implemented. These elements can be useful in your next Go application. Moreover, we have seen how it was possible to implement a complex application with a few lines of Go.</p><p>Finally, here’s some references for the article:</p><ul><li>All the source code of Bashy is open, and you can find it on GitHub <a href="https://github.com/zeppaman/bashy">https://github.com/zeppaman/bashy</a></li><li>The library I used for argument parsing is available at <a href="https://github.com/urfave/cli">https://github.com/urfave/cli</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4bf28b39956" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/bash-argument-parsing-e4bf28b39956">How I Created a Script Engine With Go</a> was originally published in <a href="https://betterprogramming.pub">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Effective Way To Write Bash Scripts]]></title>
            <link>https://medium.com/better-programming/effective-bash-scripts-108d976026bc?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/108d976026bc</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 15:44:43 GMT</pubDate>
            <atom:updated>2022-06-14T08:18:35.404Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to use the Bashy library for a better input parsing and script management</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-wHZXRiOreqymsRm" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Nowadays, most of the tools and scripting engines have some very important features that save us tons of hours. In my daily work, I appreciate these scripts the most:</p><ul><li>argument parsing and help support: the ability to self-document the command you are launching, enumerating all the parameters</li><li>script share: the opportunity of sharing the scripts that you created with others.</li></ul><p>Both of the features are accomplished by modern languages. Just think about it, in node, .net, or PHP, you have a repository of packages and you can download executables that the package manager installs in your local. This way, content can be used to share the programs you have created with others using the public or private repository.</p><p>All those languages offer (directly or using easy-to-integrate libraries) a way to freely build the information about the console commands and the options listing. Moreover, that solution also resolves the argument parsing issue. But what about bash?</p><p>In this article, we will discover <a href="https://github.com/zeppaman/bashy">Bashy</a>, a tool written in Go that aims to solve all these issues by empowering BASH scripts to parse arguments using declarative manifest and script sharing.</p><p>Let’s see it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OVyLhe0wxMKtHTdc" /><figcaption>Photo by <a href="https://unsplash.com/es/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Bash Manifests and Argument Parsing</h3><p>I’m sure that most of us like the fact that if you type --help after a command (eg. mytool --help) you get all the options and parameters. Well, how much of you like to write the code for implementing that? In the most advanced languages (C#, GO, PHP) there are libraries and helpers for doing so, but in bash, the most common option is to write something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5e7bb5203f6a06e99821d9e8e3d26c9/href">https://medium.com/media/a5e7bb5203f6a06e99821d9e8e3d26c9/href</a></iframe><p>As you can see, this code is not easy to maintain and you have to update it each time you will add a parameter. How our lives will change with Bashy!</p><p>This is the same using Bashy (arguments are automatically parsed):</p><pre>echo &quot;FILE EXTENSION  = ${EXTENSION}&quot;<br>echo &quot;SEARCH PATH     = ${SEARCHPATH}&quot;<br>echo &quot;DEFAULT         = ${DEFAULT}&quot;<br>echo &quot;Number files in SEARCH PATH with EXTENSION:&quot; $(ls -1 &quot;${SEARCHPATH}&quot;/*.&quot;${EXTENSION}&quot; | wc -l)</pre><p>How it is possible? Bashy uses a descriptive format for our scripts. So, we will be able to explain the parameters to the script just by adding some lines of a YAML config file. So, the interpreter will know how parameters are made, and you will get variables populated with the right values. Easier, right?</p><p>In the following snippet, you will find the YAML description for a simple script that shows input data. You can embed the bash script inside the manifest or link to an external file. In this example, I used an embedded one for brevity, as you can see below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87e7b5d3a50d6daed0fca6fc241beaa4/href">https://medium.com/media/87e7b5d3a50d6daed0fca6fc241beaa4/href</a></iframe><p>Now that we’ve seen how things became easier, let’s start creating our first bash script.</p><h3>How To Create Your First Bashy Script</h3><p>As we introduced in the previous section, a Bashy script is no more than a regular BASH script with a manifest associated. The Bashy interpreter wraps the scripts by parsing the argument with the information in the YAML manifest, serving the values to your script, and injecting them as regular variables.</p><p>This makes magic!</p><p>For short scripts, you can embed the bash code inside the YAML file directly. Of course, the longer script can be kept as external standalone files. With these, you’ll add the path to the file (it can be also an URL allowing download from the internet).</p><p>In this article, I will always use the embedded version to simplify the read by avoiding multiple snippets for each step of the tutorial.</p><p>The first step is to create a YAML file in with you can fill all the metadata like in the snippet below:</p><pre>name: Name<br>description: the command description<br>argsusage: help text</pre><p>The name of the command will be the one used for invoking the script. Meanwhile, description and arg usage will be used to display the help text. The other element for describing the command is the argument list. We can add it by the config element params:</p><pre>params:<br>- name: &quot;name&quot;<br>  desc: &quot;enter your name&quot;<br>- name: &quot;surname&quot;<br>  desc: &quot;enter your surname&quot;</pre><p>Now, we can add the script command. It can be added in place, line by line, or you can link to an external script. All the ways can coexist and will be executed in order. In this case, we are using the embed version:</p><pre>cmd: echo &quot;commmand executing with $name and $surname&quot; </pre><p>Then, you can get the input values by using the variables. Each input will have a variable with the name you choose in the manifest. In our case, they are $nameand $surname.</p><p>You can test it by adding it to the repository:</p><pre>bashy repo add ./samples/bash.yml</pre><p>Now, the script is available, and you can check it by typing:</p><pre># basky Name<br>NAME:<br>   main Name -</pre><pre>USAGE:<br>   main Name [command options] [arguments...]</pre><pre>DESCRIPTION:<br>   the command description</pre><pre>OPTIONS:<br>   --name value     enter your name<br>   --surname value  enter your surname<br>   --help, -h       show help (default: false)</pre><p>The execution of the script just needs:</p><pre># basky Name --name myname --surname mysurname</pre><pre>commmand executing with myname and mysurname</pre><p>Then, if you had included the bin folder of bashy to the path file you can call directly the command as it was a physical script:</p><pre>Name --name myname --surname mysurname # No &quot;bahy&quot; command here</pre><pre>commmand executing with myname and mysurname</pre><p>That’s it. Now that your first script is done, see how to share it with others.</p><h3>Deploy and Consume a Script</h3><p>Like the most common package manager, Bashy can download artefacts in your local. Because it is estimated to an internal user (bash scripts are used mostly by technicians), it is thought to be as smoother as possible.</p><p>In fact, Bashy downloads and installs any YAML file — local or via HTTP. This means that your team can share files by publishing them to a shared folder or to any HTTP repository (websites or artefact repository). This part is very good because it doesn&#39;t force you to install and adopt (and maybe pay) any third-party tools.</p><p>The command for adding a script to your local repository is:</p><pre># bashy repo add <a href="https://raw.githubusercontent.com/zeppaman/bashy/master/samples/bash.yml">https://raw.githubusercontent.com/zeppaman/bashy/master/samples/bash.yml</a></pre><pre>List of the script added:<br>/root/.bashy/scripts/Name.yml<br>/root/.bashy/scripts/SecondCommand.yml<br>/root/.bashy/scripts/RemoteCommand.yml</pre><p>Now the command is available, and you can use the script!</p><h3>Conclusion</h3><p>In this article, we have seen how to use Bashy to simplify the BASH script usage. This tool enhances Bash script to be in compliance with the newest standards, and it saves us tons of hours. In other words, it helps us to increase the quality and delivery of more efficient scripts with the same effort.</p><p>So, you just have to test it 😃.</p><p><em>Loved the article? Become a </em><a href="https://daniele-fontani.medium.com/membership"><em>Medium member</em></a><em> to continue learning without limits. I’ll receive a portion of your membership fee if you use the following link, at no extra cost to you.</em></p><h3>References</h3><ul><li>Repo on GitHub <a href="https://github.com/zeppaman/bashy">https://github.com/zeppaman/bashy</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=108d976026bc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/effective-bash-scripts-108d976026bc">The Effective Way To Write Bash Scripts</a> was originally published in <a href="https://betterprogramming.pub">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The new age of Social Networks]]></title>
            <link>https://daniele-fontani.medium.com/the-new-age-of-social-networks-50c80dbed246?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/50c80dbed246</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[content-marketing]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[facebook]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Mon, 13 Dec 2021 12:43:40 GMT</pubDate>
            <atom:updated>2021-12-13T12:43:40.940Z</atom:updated>
            <content:encoded><![CDATA[<h4>From social networks to content networks</h4><p>In the last days, the announcement of <a href="https://medium.com/u/c79346ea7c9a">Mark Zuckerberg</a> of changing the name of Facebook went around. This news caused a stir and was something that most of us cannot expect. Anyway, those who were looking to social networks in a detached manner, already discover that something was (and it’s) changing.</p><p>In this article, I will try to retrace the history of social networks, understand why the new stars are replacing the old ones, and what will be the driver for the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M4b47jmkRUQCmW-y" /><figcaption>Photo by <a href="https://unsplash.com/@gpthree?utm_source=medium&amp;utm_medium=referral">George Pagan III</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The early age of social networks</h3><p>I’m one of the first age social network adapters when facebook landed in Italy in early 2008. At that time, having a Facebook account was cool and a status symbol of young and smart people (not all had had an internet connection, a PC, etc…). Anyway, when a few years later the smartphone brings a pc with an internet connection inside the pocket of everybody — and at an affordable price — there wasn&#39;t any more barrier between the social networks and the masses. This is what happened in Italy based on my experience, but I suppose that it was the same in other countries, maybe with different timing (probably this happen years before into the country that was more technologized).</p><h3>The maturity of social networks</h3><p>Well, since that time, social networks spread and become part of our daily life. New social networks were born, some of them died. Somebody became addicted, others are detoxing from the social networks. We passed from sharing the status message in the early Facebook to post a message like an SMS on Twitter, from sharing our photo when we are on vacation, to watch hundreds of videos in a minute on Tick Tock. We passed from sharing our CV on Linkedin to funny videos during the working hours — still on Linkedin.</p><blockquote>And finally the announcement of Mark Zuckerberg. What’s going wrong with Social Networks?</blockquote><p>In the next sections of this article, I will try to analyse what is the problem of social networks and what is their future based on the changes that are happening.</p><h3>The dinosaurs and the new stars</h3><p>This trend is confirmed by <a href="https://www.statista.com/statistics/264810/number-of-monthly-active-facebook-users-worldwide/">statista.com</a> where you can see how in the first quarter of 2021 the number of new users dropped to 11% from 41% in 2021. It’s not so different for Twitter, which grow only 2,5% in the last year (source: <a href="https://www.statista.com/statistics/303681/twitter-users-worldwide/">statista.com</a>). Think also that in this number are included fake accounts and dead accounts. So, apparently, the early day&#39;s social networks are coming to an end. On the other hand, new stars are coming. We assisted in the rise of Tik Tok, for example. So, what is wrong with older social media?</p><h3>Who makes a profit with social networks?</h3><p>If I tell that social networks are big advertising machines, it will be a rough approximation, but it’s a fact that social networks make profits selling marketing campaigns. Moreover, people that interact with them are the reason that leads companies to spend on social campaigns. I’m don&#39;t telling you this is good or not, I’m simply telling you how it works.</p><p>While you are watching other people’s business on the social network many videos or posts ask you to do some action (sponsored or not). This makes the social network a good lake where to fish customers.</p><blockquote>For example, you probably land on this article from a social network post!</blockquote><p>The user produces content (just publish photos or share comments), friends watch them and comment on them. Such comments are often spontaneous and simples. So, there are networks of people (the social network) that daily produces contents and consume them autonomously. The only matter is that the content they produce is mostly thrashing. People start to begin tired of paying the cost of being bombarded by advertising and poor content for having the benefit of making the other people’s business and sharing their facts. But how people can keep in touch? The Covid crisis tech us how digital media are useful for keeping in touch! This can be done by private or local networks, like Telegram or Whatsapp groups.</p><h3>A new model is coming</h3><p>What I’ve seen in the last years is a more sustainable kind of social network. Think about <a href="https://medium.com/u/504c7870fdb6">Medium</a>, for example. It is ads-free and drives most of their income to the authors. This model is sustainable and encourages authors to write good pieces.</p><p>Another case is <a href="https://onlyfans.com/">OnlyFans </a>that made their business on the content producer that is sponsored to the fans. Even in this case, the driver is to encourage (with money) authors to deliver good quality content.</p><p>Moreover, Twitter launched their <a href="https://help.twitter.com/it/using-twitter/spaces">Twitter Spaces</a> that allow users to pay a ticket for entering someone space.</p><blockquote>We are moving from social media to the content producer.</blockquote><h3>What to take home</h3><p>The upcoming smart way to communicate and to create small communities like <a href="https://medium.com/u/dca24e3a130c">Telegram Messenger</a> or Whatsapp reduce the need of keeping in touch by publishing personal content on social media. Think also to killer apps like <a href="https://medium.com/u/be36e94a7e47">Google</a> Photo, which shares albums and photos between relatives and friends. With that premises, it’s logical that a lot of content won&#39;t transit from traditional social media in the future and people will open them only if he is sure to find high-quality content. It can be funny videos, good articles, news… but they will expect to find good quality resources, not only cat photos or thousands of posts with epic titles that end with nonsense content.</p><p>Said that there is a revolution in the act on social media. Adding an economic incentive to the producer is a good way to incentivize the good ones to go on and will make it possible to create value, not only advertisements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50c80dbed246" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Much Micro Is Needed To Create a Microservice?]]></title>
            <link>https://medium.com/better-programming/microservice-macroservice-f483f9797246?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/f483f9797246</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Wed, 17 Nov 2021 13:35:37 GMT</pubDate>
            <atom:updated>2021-11-17T13:35:37.517Z</atom:updated>
            <content:encoded><![CDATA[<h4>A simple rule to avoid throwing your project into the trash</h4><figure><img alt="Cactus next to measuring tape" src="https://cdn-images-1.medium.com/max/1024/0*-saXeH79WCCHgLYJ" /><figcaption>Photo by <a href="https://unsplash.com/@charlesdeluvio?utm_source=medium&amp;utm_medium=referral">Charles Deluvio</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Microservices is one of the bigger trends of architectural design. In the last years, most of the software was built on top of this pillar and a lot of people experience very good results. Microservices can provide improvements to performance, scalability, and reduce maintenance costs. Anyway, as I described in my article, <a href="https://betterprogramming.pub/microservice-pros-cons-69ffe8c39faf">“Microservices Are Not a Silver Bullet. Learn Why,”</a> there is one dark side. If you are not implementing microservice in the proper way, you may lose all the advantages plus keep all the problems of monolithic applications. This is a hard notion, but we must make matters clear.</p><p>In this article, I will try to give some input about one of the most important factors in microservices implementation: the scope. In other words, how much “micro” should be a microservice?</p><h3>Why Focus on the Size</h3><p>Microservice architecture is a technique that connects the data model with the business model. This makes it possible to evolve different business aria with a separate team. As the <em>divide et impera</em> law teaches, having multiple small codebases is easier than managing a huge monolithic application. So, at first look, it seems an easy question: just splice the application code.</p><blockquote>Making the wrong cut is the most common error and the first reason for microservice failure.</blockquote><p>In fact, microservice works well when you have a standalone, independent application built on a specific domain or subdomain.</p><blockquote>Often, defining the model boundaries is more a bet than a science.</blockquote><p>In the next section, we will see what are the side effects of having a scope that is too big or small and then how to define the right size for getting the best for our application.</p><h3>Too Big Is Bad</h3><p>To prove that having a too big application domain is bad just think about the case when you have a microservice that’s big like your monolithic applications. You could argue that this is not a microservice at all! Well, what if the microservice domain is very big? It’s intuitive that the more the microservice is huge and more you will lose the benefit of having a small application to manage. This is not only a problem of that amount of code but the complexity in the management. So, speaking clear, if you have a scope that is too big for your data model, you are not using microservices, you are just adding a cool label to your project.</p><p>And this is not our goal as software architects. We should find ways for implementing a robust solution, not look nice with our colleagues. So, we all agreed that a huge application domain is bad, so the easier solution is to split it into smaller parts, but how much small? As small as possible, you will tell. Let’s see in the next section what are the problems that emerge when you exaggerate.</p><h3>Too Small Is Bad</h3><p>To bring things to the extreme you can think to have a single microservice as small as possible. You could think of a CRUD application, so an API that operates on a single entity. You may tell me that dividing the single operations (read, create, update…) will be a more “small” solution, but I do not need to go so deep for proving that having a small application can introduce problems.</p><p>Coming back to our CRUD microservice, suppose to have the entity “Setting” managed by the microservice. That could be a simple key pair table that contains settings for the application. That’s super easy and works because the domain matches exactly the scope of the application. But now think of two different API applications, one manages ordered, and the second one the order rows. Well, as you can imagine, using them that way is a mess because you should add the order, then the order rows, then update the order with the total.</p><p>This is very hard to use because you are implicitly delegating your business logic to the caller. This may cause different behaviour based on the caller usage of the API. For example, the user can arbitrarily update the order total or not after changing an order item row. Moreover, the order addition is not ACID, so if you break something during the order write (remember: add order, add rows, then update total…) you may have inconsistent data.</p><blockquote>This example explains that splitting the domain model split also business logic creating complexity and leading to unwanted beaviours.</blockquote><p>We have seen that too big is bad but so is too small. So what’s the right size? Just jump to the next section to discover it.</p><h3>Fit the Domain Needed</h3><p>One rule given is to keep the data model auto-consistent. In other words, never split the domain model. Of course, we are not talking about the whole application domain. For example, if you are creating e-commerce on microservices you may have different domains for the application scope (CRM, CMS, E-commerce) and you can divide the big problem into smaller. What it’s more problematic is to divide the CMS part into two different microservices, one for the categories and one for the pages. This would be too much and will lead to unmanageable software.</p><blockquote>The approach of having the domain model as boundaries is very good but is not always “micro.”</blockquote><p>To break this deadlock, programmers created a new term: macro services. This probably helps to keep their peace of mind and leads to great results because it grants that we have done the best possible in the domain application minification.</p><p>Well, finally we understand is the right size for microservices. But I’m going to tell you that there is another problem. Just read the next section to discover it.</p><h3>Lying to Yourself Is Bad</h3><p>Now that we clarified the right scope for our microservice application, just understand what problem we can find. Here is a list based on my experience (if you have some other warning point, just add a response to this article to contribute!):</p><ul><li><strong>Surrender to the domain model:</strong> It’s easy to tell I have a monolithic domain, no way to split it. So, really ask if the dependency you have between components is really unbreakable and if you can refactor the domain to make them autonomous.</li><li><strong>Denaturate the domain model: </strong>if your business requirements need a complex scope, trying to split it may result in an academic exercise but not on an improvement of quality and maintainability</li><li><strong>Mixing apple with oranges:</strong> If your domain model is made of apples and oranges, you can separate the two fruits into two different baskets. But if you mix them when you put them into the basket you won’t have any benefits.</li><li><strong>Hiding the fact you are not using microservice: </strong>not using microservices is not a shame. The only problem is when you think you are using it and you set up your application like if you were doing so. This may lead to overkill solutions or misunderstandings in the development team.</li></ul><h3>Take Home Message</h3><p>You are not forced to use microservices. Microservice is an approach that can help your application be more maintainable and scalable. Anyway, this approach is not always applicable. Some limitations may come from the team (not an expert in this approach, no skill), by the size of the project (the project may be so small that there was any substantial benefit) or by the domain model. In this article, we have discussed the right size of the domain model and how to deal with the single microservice’s scope.</p><p>Once again, there isn’t any written rule. The only thing to remember is to never denature the business model and do not fear the size, but try to split the monolith according to your domain model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f483f9797246" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/microservice-macroservice-f483f9797246">How Much Micro Is Needed To Create a Microservice?</a> was originally published in <a href="https://betterprogramming.pub">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps Resources]]></title>
            <link>https://daniele-fontani.medium.com/devops-resources-976e93540385?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/976e93540385</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Tue, 09 Nov 2021 14:53:08 GMT</pubDate>
            <atom:updated>2021-11-09T14:53:08.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>What you can&#39;t miss about DevOps</h4><p>DevOps is one of the most huge trends in development. In this article, I collected some resources that can help to focus on the right aspects of this discipline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXgMpViitEeHe4uxIUML-A.png" /><figcaption>made with ❤️by the author</figcaption></figure><h3>APP OPS</h3><p>Focusing on infrastructure management is funny but not sustainable for our business. The goal of a modern developer is to focus on product development by adopting tools that simplify infrastructure management. If you think it’s not possible or you are curious about how to do that, just read the next article.</p><p><a href="https://betterprogramming.pub/devops-appops-f096cdbb02ac">DevOps Is Dead, Long Live AppOps</a></p><h3><strong>NoOps</strong></h3><p>Like in that AppOps stream, the NoOps fanatics aims to reduce the friction between infrastructure and developers by removing all the operation layers. This may seem like shock therapy, but the will of reducing frictions and simplify the deployment process is very cool, so I suggest reading this article to learn more.</p><p><a href="https://betterprogramming.pub/devop-noops-difference-504dfc4e9faa">DevOps Is Dead, Long Live NoOps</a></p><h3>Trends</h3><p>As I said at the beginning of the article, near the DevOps topic there are hundreds of trends and buzzwords. I tried to analyze them and I summarized the most important ones in the next article. Just read to keep you updated 😃</p><p><a href="https://towardsdatascience.com/devops-trends-8ccbed85e7af">DevOps, the Next Level</a></p><h3>Security is not an option</h3><p>Integrating security in the DevOps process is the key for keep an application secure. This can be done without blocking the application before going live and limiting rework. How? Using DevOps, of course. You can find more info in the next article.</p><p><a href="https://towardsdatascience.com/what-is-devsecops-a5f82196ad92">What exactly is DevSecOps</a></p><h3><strong>Finance is also important</strong></h3><p>We always focus on performance and security, but cloud finance can make the difference between a profitable business or not. Each service that you use has a cost and often hidden costs. Read the next article to discover what is FinOps and how it can help you to save money and get the best from the cloud.</p><p><a href="https://betterprogramming.pub/devops-noops-finops-64e0df91bcb8">DevOps, NoOps, and Now FinOps?</a></p><p><em>Loved the article? Become a </em><a href="https://daniele-fontani.medium.com/membership"><em>Medium member</em></a><em> to continue learning without limits. I’ll receive a portion of your membership fee if you use the following link, with no extra cost to you.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=976e93540385" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Modular SPA with Vue.js]]></title>
            <link>https://levelup.gitconnected.com/creating-a-modular-spa-with-vue-js-e11e200634d2?source=rss-97d01fcd4684------2</link>
            <guid isPermaLink="false">https://medium.com/p/e11e200634d2</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Daniele Fontani]]></dc:creator>
            <pubDate>Tue, 02 Nov 2021 02:39:23 GMT</pubDate>
            <atom:updated>2021-11-02T02:39:23.174Z</atom:updated>
            <content:encoded><![CDATA[<h4>Extending your application dynamically it’s possible. Learn how.</h4><p>The development workflow on SPA is quite standard. You add files to the code base, you build them, and the static output is published somewhere. This is very easy but monolithic (you can have multiple modules into the same application, but you basically put them all in an immutable artifact).</p><p>Anyway, an application like this it’s hard to maintain if you think about the big revolution that we have with micro frontends (for who it’s new to this concept, just think about what happens with microservices on the backend side applied on the frontend). Many micro frontend frameworks still start with the compilation of multiple SPA embedded into one single container or in the approach of mixing all the single components and then building them together.</p><p>In this article, I will show another approach. I will use dynamic components to include features at runtime, without the compilation step. Of course, this way doesn&#39;t offer some feature of the full transpilation (eg. output optimization) but can be a good solution in some non-performance-critical applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cEmcWQzqGABDSq_k" /><figcaption>Photo by <a href="https://unsplash.com/@greysonjoralemon?utm_source=medium&amp;utm_medium=referral">Greyson Joralemon</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The architecture</h3><p>The architecture of this application is quite easy. I want to have an application divided into modules, where each module is available by an HTTP URL (also in a different server than the main application). Each module can contain multiple components that can interact with each other sending messages. These requirements can be translated into the next architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmRn_25jCldHwQc8TUPADA.png" /></figure><p>The main application has a bag for hosting all services and distributing them to all the modules. In the same way, it holds all the components and routing rules defined in modules. So, the expected behaviour is quite easy. The application start, activate all modules defined into the module catalogue, then get all the service definition from the module, inject the services into the modules. Finally, it loads all the components and routing definitions so that the main application could mix all the features together.</p><h3>The dynamic component</h3><p>The core part of the app engine is to load dynamically a Vue component from a file. What I expect as the final result is to be able to invoke something like</p><pre>export default  extend(&quot;login&quot;,{<br>//..component definition<br>template: &quot;/path/to/template&quot;</pre><pre>})</pre><p>In the previous snippet, I have the opportunity to specify a custom template path or simply use a rule-based on naming convention (template is expected in /templates/&lt;name of the component&gt;.vue .</p><p>The next snippet contains the implementation of the extend method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcd88ed4c73b0247c08c3703acb5b3d3/href">https://medium.com/media/fcd88ed4c73b0247c08c3703acb5b3d3/href</a></iframe><p>Now that we are able to activate dynamic components we have just to create a module system and a bootstrap mechanism. Let’s see it in the next section.</p><h3>The module definition</h3><p>The module definition of javascript is a good starting point to create a module for our dynamic system. The only problem is that each module has to be loaded dynamically, even through HTTP resources. This can be done using the import keyword as a function, so calling something like let modulet=await import(&#39;path to file&#39;) . This is quite easy and if we give the module some convention we can invoke some special methods for interacting with the module. I’m talking about injecting services, getting service definitions or simply getting the routes for the module. The next snippet shows the module prototype.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ecbc66882b119d698085efdf22bf134/href">https://medium.com/media/5ecbc66882b119d698085efdf22bf134/href</a></iframe><p>The module bootstrapping is no more than a for-each loop over a collection of URLs and a series of method calls. See the next snippet.</p><pre>loadModules =async() =&gt;    {           <br>  for (const [key, value] of Object.entries(this.config.modules)){<br>  let module=await import(value);<br>  this.modules[key]=module.default;         <br>  }    <br>};</pre><p>Then it’s easy to imagine that for each API on the module prototype there will be an invocation. In the next snippet, there is an example of the service injection.</p><pre>registerServices= async ()=&gt;   {<br>  for (const [key, value] of Object.entries(this.modules) ){<br>     if (typeof value.registerServices !== &quot;undefined&quot;) {<br>      await value.registerServices(this.services,this);<br>     }<br>  };<br>};</pre><p>Summarizing the module step, we can create as many modules as we want, we can deploy them on different servers and then, dynamically, the main application will load them without recompiling anything. This will allow your user to get hit CTRL+F5 on their browser and get immediately an updated version of the website. You can also have a customized version of the application per user or profile as the module loading is completely dynamic.</p><h3>What to take home</h3><p>Making a modular application it’s possible in many ways. This artisanal solution with Vue.js ad a few lines of code is what I used for building <a href="https://github.com/zeppaman/api-farm">Api Farm</a>, the headless low-code platform.</p><p>As you learned in this tutorial, thanks to Vue.js flexibility, we can integrate modules at runtime and scale our application in terms of features with ease.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e11e200634d2" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/creating-a-modular-spa-with-vue-js-e11e200634d2">Creating a Modular SPA with Vue.js</a> was originally published in <a href="https://levelup.gitconnected.com">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>