<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Navicstein Rotciv</title>
    <description>The latest articles on Forem by Navicstein Rotciv (@navicsteinr).</description>
    <link>https://forem.com/navicsteinr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F252207%2F31b19523-945b-43eb-a4a3-361e90188683.jpeg</url>
      <title>Forem: Navicstein Rotciv</title>
      <link>https://forem.com/navicsteinr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/navicsteinr"/>
    <language>en</language>
    <item>
      <title>What is defensive programming?</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Sun, 11 Sep 2022 03:03:51 +0000</pubDate>
      <link>https://forem.com/navicsteinr/introduction-to-defensive-programming-for-beginners-2jke</link>
      <guid>https://forem.com/navicsteinr/introduction-to-defensive-programming-for-beginners-2jke</guid>
      <description>&lt;h2&gt;
  
  
  What is defensive programming?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Defensive programming is a form of defensive design intended to develop programs that are capable of detect potential security abnormalities and make predetermined response - Wikipedia &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;in other words, defensive programming is writing code to handle cases that you do not think will, or even can happen, because you have a belief that your own beliefs are unreliable or assuming the worst case: that your users are complete crazy people and you must defend yourself and your program from their crazy inputs&lt;/p&gt;

&lt;p&gt;for example, lets take a function that add two numbers and yields an output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c"&gt;// gracefully return and error&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"can't add zero values"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c"&gt;// finally compute the function&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, errors are checked before the resulting operation is done&lt;/p&gt;

&lt;p&gt;You can fight logical errors with unit tests that cover all code paths using code coverage tools for example, you can write a test to guard against zero values&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"testing"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;`TestAdd = %d, error -&amp;gt; %s`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which fails&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Running tool: /opt/go/bin/go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-timeout&lt;/span&gt; 30s &lt;span class="nt"&gt;-run&lt;/span&gt; ^TestAdd&lt;span class="nv"&gt;$ &lt;/span&gt;github.com/navicstein/def

&lt;span class="nt"&gt;---&lt;/span&gt; FAIL: TestAdd &lt;span class="o"&gt;(&lt;/span&gt;0.00s&lt;span class="o"&gt;)&lt;/span&gt;
    /home/navicstein/Idea/def/main_test.go:9: TestAdd &lt;span class="o"&gt;=&lt;/span&gt; 0, error -&amp;gt; can&lt;span class="s1"&gt;'t add zero values
FAIL
FAIL    github.com/navicstein/def   0.002s
FAIL
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a static language like C or Go, the compiler would perform some of the sanity checks for us, for example not allowing to pass string where a number is expected.&lt;/p&gt;

&lt;p&gt;There are three sources of errors to guard against&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Logical errors in the code itself.&lt;/li&gt;
&lt;li&gt;Errors in the input data, especially user supplied input.&lt;/li&gt;
&lt;li&gt;Errors in the environment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;let's look at another real world example, in this example we're going to assume we'll actually convert any video to an .mp4 video file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"errors"&lt;/span&gt;
    &lt;span class="s"&gt;"log"&lt;/span&gt;
    &lt;span class="s"&gt;"path/filepath"&lt;/span&gt;
    &lt;span class="s"&gt;"strings"&lt;/span&gt;
    &lt;span class="s"&gt;"time"&lt;/span&gt;

    &lt;span class="s"&gt;"golang.org/x/exp/slices"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;VideoParams&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Url&lt;/span&gt;          &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;AudioBitrate&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;VideoBitrate&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;VideoCodec&lt;/span&gt;   &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;AudioCodec&lt;/span&gt;   &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// ConvertAnyVideoToMp4 converts any video to mp4&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;ConvertAnyVideoToMp4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="n"&gt;VideoParams&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Url&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"an input URL is required, please provide one"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;fileExt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Ext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;exts&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;".flv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;".avi"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// don't convert video is already an mp4 file&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToLower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fileExt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;".mp4"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"video is alread an mp4 file, nothing to do"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c"&gt;// validate against supported files&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;slices&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fileExt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"unsupported video file"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c"&gt;// Here, we're just supplying defaults as we can tolerate the nil arguments&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AudioBitrate&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AudioBitrate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"8k"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;VideoBitrate&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;VideoBitrate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"30k"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AudioCodec&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AudioCodec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"mp3"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;VideoCodec&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;VideoCodec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"4264"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;doneCh&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;chan&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Converting with: %#v"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AfterFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Second&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;doneCh&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="n"&gt;doneCh&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Finished converting video to mp4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in our usage file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;    &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;VideoParams&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Url&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"https://sample-videos.com/video123/flv/720/big_buck_bunny_720p_1mb.flv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;ConvertAnyVideoToMp4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which we can see that we have default values for attributes that were not specified by the user&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;❯ go run &lt;span class="nb"&gt;.&lt;/span&gt;
2022/09/11 03:40:12 Converting with: main.VideoParams&lt;span class="o"&gt;{&lt;/span&gt;Url:&lt;span class="s2"&gt;"https://sample-videos.com/video123/flv/720/big_buck_bunny_720p_1mb.flv"&lt;/span&gt;, AudioBitrate:&lt;span class="s2"&gt;"8k"&lt;/span&gt;, VideoBitrate:&lt;span class="s2"&gt;"30k"&lt;/span&gt;, VideoCodec:&lt;span class="s2"&gt;"4264"&lt;/span&gt;, AudioCodec:&lt;span class="s2"&gt;"mp3"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2022/09/11 03:40:17 Finished converting video to mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the example above, we're just checking and setting defaults then overriding the defaults with user defined attributes but It's a good practice to write test cases before the actual implementation of a function because it gives you a clear representation of what the function will do&lt;/p&gt;

&lt;h2&gt;
  
  
  Difference between defensive programming and exception handling
&lt;/h2&gt;

&lt;p&gt;The term “defensive programming” seems to have two complementary meanings. In the first meaning, the&lt;br&gt;
term is used to describe a programming style based on assertions, where you explicitly assert any assumptions&lt;br&gt;
that should hold true as long as the software operates correctly.&lt;br&gt;
In the other meaning, however, “defensive programming” denotes a programming style that aims at making&lt;br&gt;
operations more robust to errors, by accepting a wider range of inputs.&lt;/p&gt;

&lt;p&gt;While&lt;br&gt;
Exception handling is the process of responding to unwanted or unexpected events when a computer program runs&lt;/p&gt;

&lt;h2&gt;
  
  
  Some key concepts to take home
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Anything that can go wrong will go wrong - Murphy's Law&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Error conditions will occur, and your code needs to deal with them (Out of memory, disk full, file missing, file corrupted, network error, etc)&lt;/li&gt;
&lt;li&gt;Software should be tested to see how it performs under various error conditions&lt;/li&gt;
&lt;li&gt;Program defensively, i.e., assume that errors are going to arise, and write code to detect them when they do.&lt;/li&gt;
&lt;li&gt;Put assertions in programs to check their state as they run, and to help readers understand how those programs are supposed to work.&lt;/li&gt;
&lt;li&gt;Use preconditions to check that the inputs to a function are safe to use.&lt;/li&gt;
&lt;li&gt;Use post conditions to check that the output from a function is safe to use.&lt;/li&gt;
&lt;li&gt;Write tests before writing code in order to help determine exactly what that code is supposed to do.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://faculty.cs.byu.edu/%7Erodham/cs240/lecture-notes/Lecture-16-ErrorHandling&amp;amp;DefensiveProgramming/Lecture-16-ErrorHandlingAndDefensiveProgramming.pdf"&gt;https://faculty.cs.byu.edu/~rodham/cs240/lecture-notes/Lecture-16-ErrorHandling&amp;amp;DefensiveProgramming/Lecture-16-ErrorHandlingAndDefensiveProgramming.pdf&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.state-machine.com/doc/Samek0308.pdf"&gt;https://www.state-machine.com/doc/Samek0308.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://glebbahmutov.com/blog/defensive-coding-examples/"&gt;https://glebbahmutov.com/blog/defensive-coding-examples/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What happened to Faker.js &amp; it's creator?</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Sat, 26 Feb 2022 20:02:34 +0000</pubDate>
      <link>https://forem.com/navicsteinr/what-happened-to-fakerjs-its-creator-2nje</link>
      <guid>https://forem.com/navicsteinr/what-happened-to-fakerjs-its-creator-2nje</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;faker.js - generate massive amounts of fake data in the browser and node.js&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Dreaming of been free
&lt;/h2&gt;

&lt;p&gt;Imagine you woke up in the morning and decided to create something to ease your repetitive task of generating data anytime you create project&lt;/p&gt;

&lt;p&gt;That’s how it started for Marak 8 years ago with the all-time favorite random JS data generation library Faker. It was a sincere and honest endeavour to freely push out such a handy tool both for huge corporations and small teams that took advantage of a faster &amp;amp; smoother seeding generator for test data.&lt;/p&gt;

&lt;p&gt;In October 2020 Marak added a commit to the Faker repository confirming the most dreaded situation in open source (Lack of funding) When you create a piece of software and people use it you expect to make money of it, but that’s not valid with open source libraries that are entirely based on donations. &lt;/p&gt;

&lt;p&gt;The countless added features to the Faker codebase over the years increased the maintenance cost and time invested into the project.&lt;/p&gt;

&lt;p&gt;It’s a known fact in the industry that no matter how great your open source library may be, if a big tech firm doesn’t sponsor it, you are pretty much broke. Marak knew this and made this point very clearly in his post that he will stop maintaining until he will receive a full salary offer since he had no income. Now, this is where it gets interesting, this final commit added to the reader file the cryptic line that still haunts me as I’m writing this article &lt;a href="https://www.reddit.com/r/opensource/comments/rwcccz/what_happened_to_fakerjs/"&gt;https://www.reddit.com/r/opensource/comments/rwcccz/what_happened_to_fakerjs/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A few days after the erasure of Faker &amp;amp; FakerCloud off the face of the internet, Marak pushed a controversial update to another of his maintained libraries colors.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  A glimpse of hope
&lt;/h2&gt;

&lt;p&gt;You can still install an older version of &lt;a href="https://github.com/faker-js/faker"&gt;faker.js &lt;/a&gt; and view the docs at &lt;a href="https://fakerjs.dev/"&gt;faker.dev&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i faker@5.5.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or alternatively, Faker is now a community project. Visit faker-js/faker, docs at &lt;a href="https://github.com/faker-js/faker"&gt;fakerjs.dev&lt;/a&gt; and use npm install &lt;a href="https://www.npmjs.com/package/@faker-js/faker"&gt;@faker-js/faker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hope you liked this content, see you later.&lt;/p&gt;

</description>
      <category>fakerjs</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How to add page transitions to a nextjs app</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Fri, 29 Jan 2021 09:40:09 +0000</pubDate>
      <link>https://forem.com/navicsteinr/how-to-add-page-transitions-to-a-nextjs-app-cok</link>
      <guid>https://forem.com/navicsteinr/how-to-add-page-transitions-to-a-nextjs-app-cok</guid>
      <description>&lt;p&gt;This tutorial assumes that you're already familiar with next.js and just what to add transitions to your pages and that you're have hope of using typescript&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1
&lt;/h1&gt;

&lt;p&gt;Install required dependency&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;react-transition-group
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you're using &lt;code&gt;Typescript&lt;/code&gt; install the types for it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; @types/react-transition-group
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 2
&lt;/h1&gt;

&lt;p&gt;create a &lt;code&gt;Transition.tsx&lt;/code&gt; component in the &lt;code&gt;component folder&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;TransitionGroup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Transition&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;ReactTransition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-transition-group&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ReactChild&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TransitionKind&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RC&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RC&lt;/span&gt;
  &lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getTransitionStyles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;entering&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`absolute`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`translateX(50px)`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;entered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`opacity &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;ms ease-in-out, transform &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;ms ease-in-out`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`translateX(0px)`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blink .3s linear 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;exiting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`opacity &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;ms ease-in-out, transform &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;ms ease-in-out`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`translateX(-50px)`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FC&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TransitionKind&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ReactChild&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;TransitionGroup&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;relative&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ReactTransition&lt;/span&gt;
        &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;enter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TIMEOUT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
            &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;getTransitionStyles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ReactTransition&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;TransitionGroup&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Transition&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 3
&lt;/h1&gt;

&lt;p&gt;Next, import this &lt;code&gt;Transition.tsx&lt;/code&gt; component to your &lt;code&gt;layouts/MainLayout&lt;/code&gt; or &lt;code&gt;_app.tsx&lt;/code&gt; if you're doing this in the _app.tsx be sure to replace &lt;code&gt;children&lt;/code&gt; with &lt;code&gt;&amp;lt;Component {...pageProps} /&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We have imported &lt;code&gt;useRouter&lt;/code&gt; from &lt;code&gt;next//router&lt;/code&gt; and passed the pathname to location props&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// import this `Transition.tsx` component to your `layouts/MainLayout` or `_app.tsx`&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Fragment&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Transition&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../components/Transition&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useRouter&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;next/router&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MainLaylout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRouter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="c1"&gt;// you may import your header and footer here too&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Transition&lt;/span&gt; &lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"min-h-screen"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Transition&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// React.memo may not be important&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MainLaylout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 4
&lt;/h1&gt;

&lt;p&gt;Now you have everything ready it's time to use the &lt;code&gt;MainLayout&lt;/code&gt; in our &lt;code&gt;pages&lt;/code&gt;..&lt;br&gt;
to use the layout, import and wrap your pages with &lt;code&gt;MainLayout&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;for example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Fragment&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="c1"&gt;// path to your main layout&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MainLayout&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;layouts/MainLayout&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;IndexPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MainLayout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; replace with your content here..&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;MainLayout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;IndexPage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wrap each of your pages with the main layout, congratulations, you've just added page transitions to a nextjs app&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>css</category>
    </item>
    <item>
      <title>Stop working for free, Should you ever work for free as a developer?</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Sat, 05 Dec 2020 09:10:50 +0000</pubDate>
      <link>https://forem.com/navicsteinr/stop-working-for-free-should-you-ever-work-for-free-as-a-developer-4n06</link>
      <guid>https://forem.com/navicsteinr/stop-working-for-free-should-you-ever-work-for-free-as-a-developer-4n06</guid>
      <description>&lt;p&gt;In general, the obvious answer is NO, don't be fooled into doing free work based on promises it will pay off for you in the end.&lt;/p&gt;

&lt;p&gt;I receive invitations to &lt;code&gt;work for free&lt;/code&gt; Sometimes clients even expect me to pay for my own data --  While that business model may work for some people -- like those who want to create the next Facebook in town -- working for free usually doesn't pay off.&lt;/p&gt;

&lt;p&gt;But let's explore this idea and have an open mind before reaching a decision.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if you have no experience as a freelance web developer?
&lt;/h3&gt;

&lt;p&gt;When I talk to new web developers about freelancing, some of them tell me they will start freelancing once they are expert developers. Some go a step further and tell me they know they need to be a veteran before they can start freelancing.&lt;/p&gt;

&lt;p&gt;You’ll get hired because people trust you, not because of your experience. Experience can build trust, but it’s not the only way to get there.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if you have no work experience to get a full-time job?
&lt;/h3&gt;

&lt;p&gt;It's not easy to get a job without experience, but it can be done. With no work experience, it can feel impossible to get a job. What do you do?&lt;/p&gt;

&lt;p&gt;My answer is: &lt;em&gt;YOU NEED EXPERIENCE&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you get experience?
&lt;/h3&gt;

&lt;p&gt;You charge for your services then you work for free. But this depends on where you live, most times, working for free means that you have other means of survival, and working efficiently means that you're surviving or have means of surviving, for example, in some parts of Africa, you need constant electricity, data, and a good PC, imagine a self-taught developer that started programing with just an old PC with 4GB RAM, in this case, you'll be limiting your experience by the number of programs the PC can carry. To work means that you have a good PC, data and in good conditions to work let alone the experience &lt;/p&gt;

&lt;h3&gt;
  
  
  You charge for your services
&lt;/h3&gt;

&lt;p&gt;This is the first thing you try, Charge for &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;ONLY&lt;/code&gt; if they don't go ahead, charge less (that's what I do) If they still don't go ahead? You do it for free (in exchange for a testimonial and to add it to your portfolio) - that's if you have enough time and little experience. &lt;/p&gt;

&lt;h3&gt;
  
  
  Working for free IS NOT a bad thing.
&lt;/h3&gt;

&lt;p&gt;Yes, in the short-term, it sucks. But in the long-term, it's beneficial.&lt;br&gt;
Working for free is TEMPORARY. Do it for 2 or 3 clients in exchange for a testimonial or portfolio experience. You get &lt;code&gt;EXPERIENCE&lt;/code&gt; and this &lt;code&gt;EXPERIENCE&lt;/code&gt; helps you land more clients or a higher paying job.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trust wins work
&lt;/h3&gt;

&lt;p&gt;When you’re new, the barriers to getting hired onto an engineering team are daunting. Freelancers have a different set of barriers, but they’re easier to negotiate. As a freelancer solving problems for businesses, it’s trust, not experience, that wins work. &lt;br&gt;
It's that simple. &lt;code&gt;EXPERIENCE&lt;/code&gt; and &lt;code&gt;CREDIBILITY&lt;/code&gt; do the selling and convincing for you. Let it convince your prospective clients. Play the long-term game. Trust me, this strategy works. I'm speaking from experience and it's worked for many other high-paying freelancers as well.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>workstations</category>
      <category>codenewbie</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Autogenerated schema types vs handcrafted one</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Mon, 02 Mar 2020 17:05:50 +0000</pubDate>
      <link>https://forem.com/navicsteinr/autogenerated-schema-types-vs-handcrafted-one-11ge</link>
      <guid>https://forem.com/navicsteinr/autogenerated-schema-types-vs-handcrafted-one-11ge</guid>
      <description>&lt;p&gt;Hello community, lately ive been wondering the advantages of auto generated schema definitions like &lt;a href="https://github.com/graphql-compose/graphql-compose-mongoose"&gt;graphql-compose-mongoose&lt;/a&gt;, in respect to hand written schema definitions, there are many things the tools generates that i don't use (ever) in my applications, i know that soon there will be a bug somewhere in anything &lt;code&gt;auto&lt;/code&gt; generated, please what does the community recommend? should i use an auto-generated tool, or carefully roll out mine by hand!&lt;/p&gt;

</description>
      <category>help</category>
      <category>graphql</category>
      <category>apollo</category>
    </item>
    <item>
      <title>Creating Neumorphic components in React, Vue and Svelte</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Mon, 03 Feb 2020 17:03:29 +0000</pubDate>
      <link>https://forem.com/navicsteinr/creating-neumorphic-components-in-react-vue-and-svelte-3fam</link>
      <guid>https://forem.com/navicsteinr/creating-neumorphic-components-in-react-vue-and-svelte-3fam</guid>
      <description>&lt;h2&gt;
  
  
  Hello everyone!
&lt;/h2&gt;

&lt;p&gt;In the next few days, I'll start creating a neumorpic component - a UI trends that's going to be popular soon.&lt;/p&gt;

&lt;p&gt;Although i draw UI inspiration from &lt;a href="https://dribbble.com/search/neumorphism" rel="noopener noreferrer"&gt;dribble&lt;/a&gt;  i didn't even know what some UI concepts was all about until i stumbled at a blog post on medium &lt;a href="https://uxdesign.cc/neumorphism-in-user-interfaces-b47cef3bf3a6" rel="noopener noreferrer"&gt;Neumorphism in user interfaces&lt;/a&gt; and since then I've been designing my applications UI with the concept but i feel like creating something new out of the spec, that's why am calling a frontend developers around to globe to help contribute in the creating of &lt;code&gt;neumo&lt;/code&gt; a neumorphic UI trend this 2020 and beyond &lt;/p&gt;

&lt;h2&gt;
  
  
  What can be achieved with this?
&lt;/h2&gt;

&lt;p&gt;if the project goes well, we would be able to achieve the following UI with our shiny project &lt;/p&gt;

&lt;p&gt;see the following screenshots to be convinced   &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F3105764%2Fscreenshots%2F9399378%2Fmedia%2F0285f7facb336eaf439ade5b00c029c7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F3105764%2Fscreenshots%2F9399378%2Fmedia%2F0285f7facb336eaf439ade5b00c029c7.png" alt="media one"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F1245976%2Fscreenshots%2F9833973%2Fmedia%2F0f9aa03ecbb204e42b6c3dcc031c143e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F1245976%2Fscreenshots%2F9833973%2Fmedia%2F0f9aa03ecbb204e42b6c3dcc031c143e.png" alt="media two"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F2202649%2Fscreenshots%2F9527558%2Fmedia%2F2caa8dfdadc4f3264149966b8132e51b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F2202649%2Fscreenshots%2F9527558%2Fmedia%2F2caa8dfdadc4f3264149966b8132e51b.png" alt="media three"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F1936371%2Fscreenshots%2F9393020%2Fmedia%2F300ef446de8fd329a81df1d4937b25b7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.dribbble.com%2Fusers%2F1936371%2Fscreenshots%2F9393020%2Fmedia%2F300ef446de8fd329a81df1d4937b25b7.png" alt="media four"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;view more &lt;a href="https://dribbble.com/search/neumorphism" rel="noopener noreferrer"&gt;here&lt;/a&gt; - that's where i got it from &lt;/p&gt;

&lt;p&gt;In the future, the specification could also introduce elements of other embed-able frameworks like vuetify, quasar for vue etc, the library should integrate well with other frameworks as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  In the project I'll use all of the following concepts and technologies (&amp;amp; more)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://storybook.js.org/" rel="noopener noreferrer"&gt;Storybook&lt;/a&gt; - open source tool for developing UI components in isolation for React, Vue, and Angular.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;Typescript&lt;/a&gt; - A typed superset of JavaScript that compiles to plain JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sass-lang.com" rel="noopener noreferrer"&gt;Sass&lt;/a&gt; - CSS with superpowers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;and more to come&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Goal
&lt;/h2&gt;

&lt;p&gt;The goal of this project is to create a neumorphic UI component framework for creating applications super fast. If everything goes well, it will be released someday!&lt;/p&gt;

&lt;h2&gt;
  
  
  Contributions are welcome!
&lt;/h2&gt;

&lt;p&gt;After I set up the initial project skeleton I'd appreciate any contributions from people who would like to collaborate in component development and/or learn hands-on.&lt;/p&gt;

</description>
      <category>react</category>
      <category>vue</category>
      <category>svelete</category>
      <category>neumorphism</category>
    </item>
    <item>
      <title>Quick tip on how to update your projects dependencies (nodejs)</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Mon, 03 Feb 2020 15:16:05 +0000</pubDate>
      <link>https://forem.com/navicsteinr/quick-tip-on-how-to-update-your-projects-dependencies-nodejs-33j9</link>
      <guid>https://forem.com/navicsteinr/quick-tip-on-how-to-update-your-projects-dependencies-nodejs-33j9</guid>
      <description>&lt;p&gt;If you want to keep your project secure, fast and enjoy the latest features of all your dependencies, it's important to keep them regularly up-to-date. since this is just a quick tip and not a full blog post, i won't go into details on why you should update your projects dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;What are they used for? Do you really need them? Are they correctly ordered between &lt;code&gt;dependencies&lt;/code&gt; and &lt;code&gt;devDependencies&lt;/code&gt;? This may sound a bit obvious but if you're working on a project that you haven't initialized or where people were free to add dependencies, I'm pretty sure that you don't have a full control of what you're using.&lt;/p&gt;

&lt;p&gt;To correctly update your dependencies and being able to adapt your code with the potential breaking changes, it's important that your dependencies contain a CHANGELOG file, some documentation or even better a migration guide.&lt;/p&gt;

&lt;p&gt;Usually, a lot of dependencies have a &lt;code&gt;CHANGELOG.md&lt;/code&gt; file at the root of their repository. This file contains the list of the changes (bugfixes / features) released with each new version. If the updates follow the semantic versioning, it'll be easier to predict if an update will be easy or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating using npm
&lt;/h2&gt;

&lt;p&gt;There's no viable way of doing this is npm but installing a global package might help, you need to install a new global dependency by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; npm-check-updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The to check for an update run the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ncu &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the &lt;code&gt;-n&lt;/code&gt; finds the newest versions available instead of the latest stable versions while the &lt;code&gt;-u&lt;/code&gt; means overwrite package file &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.npmjs.com/package/npm-check-updates"&gt;https://www.npmjs.com/package/npm-check-updates&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Updating using yarn
&lt;/h2&gt;

&lt;p&gt;By default, Yarn allows you to upgrade your dependencies in an interactive way. You just have to run &lt;code&gt;yarn upgrade-interactive&lt;/code&gt; and you'll be prompted with all the possible updates (that follows the versions you've set in your package.json file) you can do.&lt;br&gt;
for example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;yarn upgrade-interactive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all, hope you enjoyed this tip consider to share it with your friends :)&lt;/p&gt;

</description>
      <category>node</category>
      <category>npm</category>
      <category>javascript</category>
      <category>strapi</category>
    </item>
    <item>
      <title>Am drowned! 😭 can someone explain what prisma and apollo is like am 12!</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Tue, 21 Jan 2020 08:18:39 +0000</pubDate>
      <link>https://forem.com/navicsteinr/am-drowned-can-someone-explain-what-prisma-and-apollo-is-like-am-12-1k8c</link>
      <guid>https://forem.com/navicsteinr/am-drowned-can-someone-explain-what-prisma-and-apollo-is-like-am-12-1k8c</guid>
      <description>&lt;p&gt;Hi everyone, I've been following graphql lately and i don't yet fully understand the difference between prisma, graphql and apollo grapghql, ive gone through their docs but the whole concept seems overwhelming i would want the community to explain how they differ from each other and what they tend to fix, Thanks&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Reasons why you should switch from Windows to Linux for development</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Sun, 24 Nov 2019 15:25:17 +0000</pubDate>
      <link>https://forem.com/navicsteinr/reasons-why-you-should-switch-from-windows-to-linux-for-development-2d8e</link>
      <guid>https://forem.com/navicsteinr/reasons-why-you-should-switch-from-windows-to-linux-for-development-2d8e</guid>
      <description>&lt;p&gt;There are a many reasons to choose desktop Linux over Windows, i'll try to be as direct as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  It's free
&lt;/h2&gt;

&lt;p&gt;Microsoft will force you to upgrade to Windows 8.1/10 which means you’ll have to spend around ₦43,500.00 just for the OS, although you can get the crack versions which might not be safe because of malicious pre-built applications in the CD-ROM&lt;/p&gt;

&lt;p&gt;Linux OS, on the other hand, is completely free and powered by the open source. If you choose to switch to Linux, you save at least a thousand Naira. Sounds good enough a reason, ain’t it?&lt;/p&gt;

&lt;h2&gt;
  
  
  Application Store
&lt;/h2&gt;

&lt;p&gt;Most of the desktop Linux OS have their own &lt;a href="https://snapcraft.io/store"&gt;"app store"&lt;/a&gt; or "software repository" just like playstore on android devices, you can easily find games, apps and other tools for work there and from a secure source.&lt;/p&gt;

&lt;p&gt;Windows also have an &lt;a href="https://www.microsoft.com/en-us/store/apps/windows"&gt;application store&lt;/a&gt; but most applications are not &lt;strong&gt;free&lt;/strong&gt;, although the applications on windows store are much  advanced or better than linux, but free and open is often better than paid in most cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Better updating process
&lt;/h2&gt;

&lt;p&gt;Windows updates are real pain. First Windows will notify that you have system updates. When you install them, it will be configured at shutdown time at a pace that even a tortoise can beat. You will be told to “preparing to configure Windows, do not shutdown your system” and the wait is eternal. And that’s not the end. At the next boot, it will again be configuring the updates. Moreover, the software and applications installed in Windows provide their updates separately. Remember Java, Adobe, VSCode and iTunes updates pop up?&lt;/p&gt;

&lt;p&gt;Updates in Linux is a like a cool breeze. You will be regularly notified that updates are available. And these updates include not just system and security updates but available updates for different applications installed. Unlike Windows, you won’t have to wait at shutdown or start time. Updating in desktop Linux is a matter of one click.&lt;br&gt;
or you can run the &lt;strong&gt;upgrade&lt;/strong&gt; and &lt;strong&gt;update&lt;/strong&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drivers included and free
&lt;/h2&gt;

&lt;p&gt;As a Windows user, you must have struggled with drivers. This always happen to me anytime i want to work on an application that requires extra configuration, finding the correct driver for your system was a difficult task for me. I remember, I had several drivers folders in my external backup disk as I did not want to waste time looking for the audio, video or wireless drivers, then i found it hard to download files through the internet. But with Linux, most of these drivers are supported directly by the Linux kernel. Which means its more like &lt;strong&gt;plug and play for Linux&lt;/strong&gt;, no struggling with drivers, largely.&lt;/p&gt;

&lt;p&gt;For example what one will usually do with a clean installation of windows is to install the necessary drivers some drivers come from &lt;a href="https://drp.su/en"&gt;&lt;strong&gt;driver pack&lt;/strong&gt;&lt;/a&gt;  and most of the drivers are too large to download, the funniest thing is that when a driver fails to install or when the internet is slow, the whole installation process will start afresh, that's a difficult thing to keep up with especially here in Nigeria where data is somehow a problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Community support
&lt;/h2&gt;

&lt;p&gt;Probably the best thing about Linux is  &lt;a href="https://ubuntu.com/community"&gt;the Linux community.&lt;/a&gt; You will never feel alone in Linux world. Apart from numerous Linux how-to blogs, just drop by any forum for any kind of problem you are facing with your system, someone will always try to help you out. Such is the support of Linux community. &lt;/p&gt;

&lt;h2&gt;
  
  
  Better commands
&lt;/h2&gt;

&lt;p&gt;As a software engineer commands aid and eases our work, windows have a very limited set of commands unless you're using  &lt;a href="http://mingw-w64.org/doku.php"&gt;mingw-w64&lt;/a&gt; which is limited and not extensible like the default terminal in Linux, another great feat is the ability to extend and theme the command shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ease of use
&lt;/h2&gt;

&lt;p&gt;The one misconception about Linux is that it is “geeks only” and one needs to be computer genius and command line ninja to use Linux. No, it is not true. It is not late 90’s where Linux was a complicated operating system. These days desktop Linux OSes run out of the box, have GUI tools and have all the functionality that you look for in Windows.&lt;/p&gt;

&lt;p&gt;I hope this post makes your decision of switching to Linux easier especially to Ubuntu. Also you can follow me on my &lt;a href="https://twitter.com/NavicsteinR"&gt;twitter handle&lt;/a&gt;. Time to ditch Windows and embrace the freedom has come. Welcome to Linux 💕! &lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>windows</category>
      <category>development</category>
    </item>
    <item>
      <title>A fair comparison of React.js and Vue.js in 2019 and beyond!</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Fri, 22 Nov 2019 19:33:50 +0000</pubDate>
      <link>https://forem.com/navicsteinr/a-fair-comparison-of-react-js-and-vue-js-in-2019-and-beyond-19l5</link>
      <guid>https://forem.com/navicsteinr/a-fair-comparison-of-react-js-and-vue-js-in-2019-and-beyond-19l5</guid>
      <description>&lt;p&gt;A lot of developers have been unfairly comparing react to vue, but the truth is that you might have  gotten some facts wrong! I'll try to be fair in this comparison &lt;/p&gt;

&lt;p&gt;Firstly let's quickly look at this chart in &lt;a href="https://trends.google.com/trends/explore?cat=31&amp;amp;q=Vue.js,React"&gt;google trends&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yCqXZBxP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/8sm1rz44rlwvjno4ca0p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yCqXZBxP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/8sm1rz44rlwvjno4ca0p.png" alt="vue vs react rotciv comparism" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll see that React wins, but let's be honest, Vue is more used in Asian Countries especially china which is the birth  home of Vue.&lt;/p&gt;

&lt;p&gt;First, it’s not fair to use &lt;a href="https://trends.google.com/trends/explore?cat=31&amp;amp;q=Vue.js,React"&gt;google charts&lt;/a&gt;  to compare framework popularity. For  instance Chinese users (where Vue is really strong) don’t have access to Google, also if the framework you choose to work with is complex or has a lot of trouble shooting you might use the search engine more in search &lt;/p&gt;

&lt;p&gt;React on the other hand is an american company, and that alone gives react a huge community support and secondly its made by a company that have already made a name. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember a good name is often better than silver and gold!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Github stars
&lt;/h2&gt;

&lt;p&gt;Some developers measure a frameworks popularity by their stargazers, lets take a look at both&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hIwvBfaH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/wb4iupa86vu3zpdvmx3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hIwvBfaH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/wb4iupa86vu3zpdvmx3b.png" alt="react stargazers" width="800" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lEl73hlR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/2m4g060q4k4guw3k2qle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lEl73hlR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/2m4g060q4k4guw3k2qle.png" alt="vue stargazers" width="800" height="49"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;ignore the other information in the pictures&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;From the little pictures there, we'll find out that Vue has about 153 thousand stars, while React has about 139 thousand stars.&lt;/p&gt;

&lt;h2&gt;
  
  
  Popularity
&lt;/h2&gt;

&lt;p&gt;&lt;br&gt;
React is more popular and searched programming technology in comparison to Vue. &lt;br&gt;
&lt;br&gt;
This statement would have been true only if Chinese developers and users are massively using google, but since the Chinese don't  do much of "our google" we can't say for sure that "X" wins "Y" but we can keep our finger crossed that in some areas "Vue" wins and in another area "React" wins it all depends on your location.&lt;br&gt;
A Chinese developer will simply tell you that Vue wins in his country since it's used more there while an American developer will tell you that React wins, this is likely to be 'the chicken and the egg problem' &lt;/p&gt;

&lt;h2&gt;
  
  
  Time Traveling
&lt;/h2&gt;

&lt;p&gt;Ok, let's put on our imagination helmet and time travel,  imagine Vue not Angular been backed by &lt;a href="https://google.com"&gt;google&lt;/a&gt;  in the year &lt;em&gt;2014&lt;/em&gt;, a year after React was created, if Vue had been backed by a huge company like google, i believe that by now React would have been not worth mentioning in 2020 despite been backed by facebook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning Curve
&lt;/h2&gt;

&lt;p&gt;The learning curve is the ability of software developers to apply the codes of a particular language/framework or library. Between these two programming technologies, Vue is more friendly for web developers according to the statistics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Material Design Component Frameworks
&lt;/h3&gt;

&lt;p&gt;While this might not be worth mentioning its very good to mention that a component frameworks eases the overhead cost of bootstrapping the UI of your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Component frameworks&lt;/strong&gt;  are sets of well-defined interfaces that establish the protocols for  &lt;strong&gt;component&lt;/strong&gt;  cooperation within the  &lt;strong&gt;framework&lt;/strong&gt;. These protocols are used by  &lt;strong&gt;component&lt;/strong&gt;  developers to ensure the interoperability of their  &lt;strong&gt;components&lt;/strong&gt;  within the scope of a given  &lt;strong&gt;framework&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's take a look at the number of matured component framework each framework has.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Vue
&lt;/h4&gt;

&lt;p&gt;We have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://quasar.dev"&gt;Quasar framework&lt;/a&gt; and &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vuetifyjs.com"&gt;Vuetify&lt;/a&gt; 
Both are very matured, material design component framework&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  For React
&lt;/h4&gt;

&lt;p&gt;We have &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://material-ui.com/"&gt;Material UI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've not heard of a component framework, it may be time to look into them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: React vs Vue
&lt;/h2&gt;

&lt;p&gt;Based on the representation of my above analysis with the help of statistics and facts, we can summarize the following points about React vs Vue:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React is more popular than Vue in the US and English speaking countries&lt;/li&gt;
&lt;li&gt;While Vue without doubt is more popular than React in Asian Countries&lt;/li&gt;
&lt;li&gt;React is backed with a top brand, facebook but Vue is not.&lt;/li&gt;
&lt;li&gt;Vue comes with &lt;code&gt;battries&lt;/code&gt;* which makes it easier than React to get started with, especially the &lt;code&gt;Vue UI&lt;/code&gt; which provides a graphical interface to work with.&lt;/li&gt;
&lt;li&gt;The production size of Vue is smaller than React, no doubt!&lt;/li&gt;
&lt;li&gt;Vue has more component frameworks than React&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of this blog, I assume that your doubts have got cleared regarding the right tech-stack for your application development. If you are still in dilemma then talk to an expert from a reputed  web app development company&lt;/p&gt;

&lt;p&gt;if you want to share your personal experience, you can reach me through the comment section at the end.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploying an app from Gitlab to Heroku using the Quasar framework and Sailsjs</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Sun, 03 Nov 2019 11:10:58 +0000</pubDate>
      <link>https://forem.com/navicsteinr/deploying-an-app-from-gitlab-to-heroku-using-the-quasar-framework-and-sailsjs-3d00</link>
      <guid>https://forem.com/navicsteinr/deploying-an-app-from-gitlab-to-heroku-using-the-quasar-framework-and-sailsjs-3d00</guid>
      <description>&lt;p&gt;In this tutorial I'm quickly going to give you an idea on how to deploy an application from heroku to Gitlab using auto CI/CD&lt;/p&gt;

&lt;p&gt;This tutorial assumes that you must have known a little bit of Quasar framework and JavaScript it also assumes that you have basic understanding of Node itself and Auto DevOps.&lt;/p&gt;

&lt;p&gt;In this example will be using Sailsjs and Quasar framework so make sure you have those dependencies installed globally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting things  ready
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; sails @quasar/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now that you have those dependency installed all you had to do is make a directory &lt;em&gt;demoapp&lt;/em&gt; as a directory name [you can change the name to your taste]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;demoapp &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;demoapp 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now create the client folder using quasar&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;quasar create client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quasar will ask you some questions about your application, make sure you answer them to your projects requirements, it also needs to download a starter kit so make sure you have an active internet connection  &lt;/p&gt;

&lt;p&gt;After creating the client folder now create the server folder, you can open a new terminal tab to speed up the development process while installing dependencies for each.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;sails new app &lt;span class="nt"&gt;--no-frontend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you should see something like this on your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜  demoapp sails new server &lt;span class="nt"&gt;--no-frontend&lt;/span&gt;
 info: Installing dependencies...
Press CTRL+C to cancel.
&lt;span class="o"&gt;(&lt;/span&gt;to skip this step &lt;span class="k"&gt;in &lt;/span&gt;the future, use &lt;span class="nt"&gt;--fast&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a new sails app without a frontend this comes handy when you want to generate a server only based application without worrying about the views since the views we are going to be replaced with quasar-framework distribution files.&lt;/p&gt;

&lt;p&gt;your root folder should look something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
├── client
│   ├── babel.config.js
│   ├── node_modules
│   ├── package.json
│   ├── package-lock.json
│   ├── quasar.conf.js
│   ├── README.md
│   └── src
├── package.json
└── server
    ├── api
    ├── app.js
    ├── config
    ├── node_modules
    ├── package.json
    ├── package-lock.json
    └── README.md

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now initialize &lt;code&gt;git&lt;/code&gt; int the root project of your application&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to add your gitlab origin to your app folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git remote add origin YOUR_APP_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up sails to load quasar dist file pragmatically
&lt;/h2&gt;

&lt;p&gt;Naturally sails is meant to load files found in the assets folder, but we want our files to be in the &lt;code&gt;views&lt;/code&gt; directory &lt;br&gt;
So we will create a directory called &lt;code&gt;views&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;from the root directory run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ./server/views
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now create a config file telling sails where our built files from quasar will be or live&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;code ./server/config/paths.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open VSCODE editor and create an empty file.&lt;br&gt;
inside the &lt;code&gt;paths.js&lt;/code&gt; file, place this code there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;paths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;public&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;views&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when you lift sails, it will load up any &lt;code&gt;index.html&lt;/code&gt; found in the views folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a buildscript
&lt;/h2&gt;

&lt;p&gt;There are many ways to archive this but i prefer to use a simple bash script to install, build and copy the files to their respective folder.&lt;/p&gt;

&lt;p&gt;Here's the &lt;code&gt;install.sh&lt;/code&gt; script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt;  &lt;span class="s1"&gt;' - Alright, here we go. trigerring auto deploy .. ..'&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;  &lt;span class="nb"&gt;echo

&lt;/span&gt;installDependencies&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt;  &lt;span class="s2"&gt;" Installing global dependencies.."&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;       &lt;span class="nb"&gt;echo
    &lt;/span&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; @quasar/cli sails
&lt;span class="o"&gt;}&lt;/span&gt;



setupServer&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt;  &lt;span class="s2"&gt;" Installing server dependencies .. .."&lt;/span&gt;
    &lt;span class="nb"&gt;cd&lt;/span&gt; ./server
    npm &lt;span class="nb"&gt;install
    cd&lt;/span&gt; ..
&lt;span class="o"&gt;}&lt;/span&gt;



setupClient&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt;  &lt;span class="s2"&gt;" Installing application dependencies .. .."&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;  &lt;span class="nb"&gt;echo
    cd&lt;/span&gt; ./client
    npm &lt;span class="nb"&gt;install
    &lt;/span&gt;quasar build &lt;span class="nt"&gt;-m&lt;/span&gt; spa
    &lt;span class="nb"&gt;cd&lt;/span&gt; ..
&lt;span class="o"&gt;}&lt;/span&gt;



copy&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt;  &lt;span class="s2"&gt;" Copying assets to server"&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;  &lt;span class="nb"&gt;echo
    mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ./server/views
    &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; ./client/dist/spa/&lt;span class="k"&gt;*&lt;/span&gt; ./server/views
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

installDependencies &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; setupServer &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; setupClient &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; copy

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What the script really does&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installs the global dependencies&lt;/li&gt;
&lt;li&gt;Uses the dependencies to build their project files&lt;/li&gt;
&lt;li&gt;Copies the built files to where the server will pick and load them up for public access.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up heroku
&lt;/h2&gt;

&lt;p&gt;First thing to do is to make sure that heroku toolbelt is installed on your machine&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; heroku
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create an Heroku's account or login using your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;heroku login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the prompt and login. After a successful login, create a project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt; heroku apps:create demoapp-ci
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the main heroku site for this but to be faster i used heroku CLI toolbelt,&lt;/p&gt;

&lt;p&gt;Naturally heroku, &lt;a href="https://devcenter.heroku.com/articles/nodejs-support#package-installation"&gt;prunes the &lt;code&gt;devDependencies&lt;/code&gt; after installing dependencies&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so to make sure that your &lt;code&gt;devDependencies&lt;/code&gt; are still there after installing your projects dependencies&lt;br&gt;
run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt; heroku config:set &lt;span class="nv"&gt;NPM_CONFIG_PRODUCTION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false &lt;/span&gt;&lt;span class="nv"&gt;YARN_PRODUCTION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; YOUR_APP_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;YOUR_APP_NAME&lt;/code&gt; is your projects application name on heroku.&lt;/p&gt;

&lt;p&gt;Heroku looks for a &lt;code&gt;start&lt;/code&gt; script in your &lt;code&gt;package.json&lt;/code&gt; file and attempts to run it with &lt;code&gt;npm start&lt;/code&gt; so create or initialize npm to create the file.&lt;/p&gt;

&lt;p&gt;From the root folder of your project run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm init &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command creates a dummy &lt;code&gt;package.json&lt;/code&gt;  in the root folder of your app. Open the &lt;code&gt;package.json&lt;/code&gt; file and add two commands in the &lt;code&gt;script&lt;/code&gt; section&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;posintall&lt;/em&gt; - runs before heroku starts your application, this is where we'll be calling the &lt;code&gt;install.sh&lt;/code&gt; script which will run and install our projects dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;start&lt;/em&gt; - this is the main entry point of our server entry file.&lt;br&gt;
Actually what we'll be doing in the &lt;code&gt;start&lt;/code&gt; section is to &lt;code&gt;cd&lt;/code&gt; into the server folder and run the &lt;code&gt;start&lt;/code&gt; script there too&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;so your &lt;code&gt;package.json&lt;/code&gt; file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"demoapp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"postinstall"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bash install.sh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cd ./server &amp;amp;&amp;amp; npm run start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"echo &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Error: no test specified&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;      &amp;amp;&amp;amp; exit 1"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="nl"&gt;"keywords"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"license"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ISC"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up Gitlab
&lt;/h2&gt;

&lt;p&gt;Now that everything is setup, we would probably be setting up Gitlab, if you don't have an account try creating one or if you already have, login into your account and create a project, we'll be using &lt;code&gt;demoapp&lt;/code&gt; as the name of the project.&lt;/p&gt;

&lt;p&gt;Now add the newly created application to your local git, i used the &lt;code&gt;SSH&lt;/code&gt; strategy in this case, you can opt-in for &lt;code&gt;HTTPS&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git remote add origin git@gitlab.com:YOUR_USERNAME/demoapp.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;replace &lt;code&gt;YOUR_USERNAME&lt;/code&gt; with your gitlab username, don't yet push now until we'v setup everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting your HEROKU_API_KEY
&lt;/h2&gt;

&lt;p&gt;This where Gitlab gets to talk to Heroku servers about your application once a code is pushed.&lt;/p&gt;

&lt;p&gt;Goto your heroku's &lt;a href="https://dashboard.heroku.com/account"&gt;dashboard&lt;/a&gt;&lt;br&gt;
under the &lt;code&gt;API Key&lt;/code&gt; section click on &lt;code&gt;reveal&lt;/code&gt; to show your API key, it should look like this &lt;code&gt;c488826c-e081-4434-a27f-45133f93c389&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now goto back to gitlab, click on the navigation menu on the left side of your browser and goto &lt;code&gt;setting &amp;gt; CI/CD&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or copy this link and replace &lt;code&gt;demoapp&lt;/code&gt; with your gitlabs project name&lt;br&gt;
&lt;a href="https://gitlab.com/navicstein/demoapp/-/settings/ci_cd"&gt;https://gitlab.com/navicstein/demoapp/-/settings/ci_cd&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;under the &lt;code&gt;Variables&lt;/code&gt; section toggle the &lt;code&gt;expand&lt;/code&gt; button&lt;br&gt;
create a key as:  &lt;code&gt;HEROKU_API_KEY&lt;/code&gt; and copy the &lt;code&gt;API Key&lt;/code&gt; from heroku into the &lt;code&gt;value&lt;/code&gt; box  then click &lt;code&gt;Save ariables&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up CI/CD
&lt;/h2&gt;

&lt;p&gt;As described by &lt;a href="https://docs.gitlab.com/ee/user/project/pages/"&gt;GitLab Pages documentation&lt;/a&gt;, everything happens with a &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file placed in the root of your repository. This working example will get you started:&lt;br&gt;
Paste this code in the root of your folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node:12.13.0&lt;/span&gt;

&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;production&lt;/span&gt;

&lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;node_modules/&lt;/span&gt;

&lt;span class="c1"&gt;# HEROKU&lt;/span&gt;
&lt;span class="na"&gt;production&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;production&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby:latest&lt;/span&gt;

&lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get update -qy&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get install -y ruby-dev&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install dpl&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;dpl --provider=heroku --app=demoapp-ci --api-key=$HEROKU_API_KEY&lt;/span&gt;

&lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the script part of the yml file&lt;br&gt;
&lt;code&gt;- dpl --provider=heroku --app=demoapp-ci&lt;/code&gt;&lt;br&gt;
replace &lt;code&gt;demoapp-ci&lt;/code&gt; with the application name you created on heroku&lt;/p&gt;
&lt;h2&gt;
  
  
  Going live
&lt;/h2&gt;

&lt;p&gt;If you come this far without any troubles, then congrats you're ready to push your code, but before that make sure you follow sails guidelines for deploying your application &lt;a href="https://sailsjs.com/documentation/concepts/deployment"&gt;sails guidelines for deploying your application&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-am&lt;/span&gt;  &lt;span class="s2"&gt;"Going live"&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pushing will&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;trigger the CI and run the jobs&lt;/li&gt;
&lt;li&gt;upload artifacts to heroku &lt;/li&gt;
&lt;li&gt;heroku in turn will run the &lt;code&gt;postinstall&lt;/code&gt; script before attempting to run the &lt;code&gt;start&lt;/code&gt; script&lt;/li&gt;
&lt;li&gt;finally, heroku will lift your app located at &lt;code&gt;./server/app.js&lt;/code&gt;
This will push and trigger gitlabs servers to run the  &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; in your folder once the build succeeds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;open your application and see your app go life, feel free to contact me or follow me on twitter when you run into issues, i'll be happy to talk with you about your project or issues you encounter.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ORM's how they simply your queries.</title>
      <dc:creator>Navicstein Rotciv</dc:creator>
      <pubDate>Thu, 17 Oct 2019 23:47:34 +0000</pubDate>
      <link>https://forem.com/navicsteinr/orm-s-how-they-simply-your-queries-52ej</link>
      <guid>https://forem.com/navicsteinr/orm-s-how-they-simply-your-queries-52ej</guid>
      <description>&lt;h2&gt;
  
  
  ORM's how they simply your queries.
&lt;/h2&gt;

&lt;p&gt;Spoiler Alert, this is directly dealing with waterline ORM&lt;/p&gt;

&lt;p&gt;In this post am going to walk you through the concept of ORM's, what they do and how they can simply your database queries.&lt;br&gt;
Before we take a deep dive into ORM, we might want to know what it stands for first, according to wikipedia.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Object-relational mapping (ORM, O/RM, and O/R mapping tool) in computer science is a programming technique for converting data between incompatible type systems using object-oriented programming languages.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Unless you've worked with NoSQL databases like mongodb or ArangoDB, you've likely written your fair share of SQL queries, they look somehow like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM users WHERE email = 'Navic_doe@mail.com'&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Object-relational-mapping is the idea of being able to write queries like the one above, as well as much more complicated ones, using the object-oriented paradigm of your preferred programming language.&lt;/p&gt;

&lt;p&gt;Here's how it'll look when writing with &lt;a href="https://waterlinejs.com"&gt;Waterlinejs&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Navic_doe@mail.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// Array -&amp;gt; do something with users&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a nutshell, we are trying to interact with our database using our language adapter of our choice,&lt;br&gt;
As you can see, we are using the waterline ORM library to execute the exact same query, except we can write it in JavaScript (or whatever language you’re using). We can use the same languages we know and love this time javascript, and also abstract away some of the complexity of interfacing directly with a database.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why use an Waterline ORM instead of writing native queries?
&lt;/h2&gt;
&lt;h4&gt;
  
  
  Database Agnosticism
&lt;/h4&gt;

&lt;p&gt;In schemaful databases like Postgres, Oracle, and MySQL, models are represented by tables. In MongoDB, they're represented by Mongo "collections". In Redis, they're represented using key/value pairs. Each database has its own distinct query dialect, and in some cases even requires installing and compiling a specific native module to connect to the server. This involves a fair amount of overhead, and garners an unsettling level of vendor lock-in to a specific database; for example, if your app uses a bunch of SQL queries, it will be very hard to switch to Mongo later, or Redis, and vice versa.&lt;/p&gt;

&lt;p&gt;Waterline  query syntax floats above all that, focusing on business logic like creating new records, fetching/searching existing records, updating records, or destroying records. No matter what database you're contacting, the usage is exactly the same. Furthermore, Waterline allows you to .populate() associations between models, even if the data for each model lives in a different database. That means you can switch your app's models from Mongo, to Postgres, to MySQL, to Redis, and back again—all without changing any code. For the times when you need low-level, database-specific functionality, Waterline provides a query interface that allows you to talk directly to your models' underlying database driver&lt;/p&gt;
&lt;h4&gt;
  
  
  Flexibility
&lt;/h4&gt;

&lt;p&gt;let's imagine you're building an e-commerce website, with an accompanying mobile app. Users browse products by category or search for products by keyword, then they buy them. That's it! Some parts of your app are quite ordinary: you have an API-driven flow for logging in, signing up, order/payment processing, resetting passwords, etc. However, you know there are a few mundane features lurking in your roadmap that will likely become more involved.&lt;/p&gt;

&lt;p&gt;You ask the business what database they would like to use:&lt;/p&gt;

&lt;p&gt;"Datab... what? Let's not be hasty, wouldn't want to make the wrong choice. I'll get ops/IT on it. Go ahead and get started though."&lt;/p&gt;

&lt;p&gt;he traditional methodology of choosing one single database for a web application/API is actually prohibitive for many production use cases. Oftentimes the application needs to maintain compatibility with one or more existing data sets, or it is necessary to use a few different types of databases for performance reasons.&lt;/p&gt;
&lt;h4&gt;
  
  
  Compatibility
&lt;/h4&gt;

&lt;p&gt;The product owner/stakeholder walks up to you and says:&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
"Oh hey by the way, the product's actually already live in our point of sale system. It's some ERP thing I guess, something like "DB2"? Anyway, I'm sure you'll figure it out. Sounds easy right?"&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Many enterprise applications must integrate with an existing database. If you're lucky, a one-time data migration may be all that's necessary, but more commonly, the existing dataset is still being modified by other applications. In order to build your app, you might need to marry data from multiple legacy systems, or with a separate dataset stored elsewhere. These datasets could live on five different servers scattered across the world! One colocated database server might house a SQL database with relational data, while another cloud server might hold a handful of Mongo or Redis collections.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are some great ORMs?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Mongoose&lt;/li&gt;
&lt;li&gt;Waterline&lt;/li&gt;
&lt;li&gt;sequelize&lt;/li&gt;
&lt;li&gt;knexjs&lt;/li&gt;
&lt;li&gt;.. etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I am a startup with a young developer team and a strict deadline, i'll prefer waterline, they are not paying me to say that, i've greatly worked with both mongoose and waterline, waterline seems to do a lot of work underneath, it tends to do a thing almost automatically without you bothering about setup cost, scaling and other factor one might consider, another thing is the adapters, i can easily use mysql and postgresql with mongodb in one big app [though the use case is rare], lemme say i want to use a mysql database in google cloud platform for only saving references of a file uploaded to s3, and a remote mongo database - say mongo atlas (see what i did there, { SQL with NoSQL } silly me :) )&lt;br&gt;
you can easily accomplish that with waterline, also waterline have a great support for cloud databases like AWS dynamodb, GCP cloud, GCP firestore etc all maintained by the official team.&lt;/p&gt;

&lt;p&gt;I'd also vouch for Mongoose, it was my first ORM love as it solves all my problem quite very well, but i wanted more, as at the time i stopped using mongoose i had a problem of populating from children nodes to parents which was already available in sails, but if am already a startup with an old codebase that just wants to keep things on the go, i'll use mongoose.&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing thoughts
&lt;/h3&gt;

&lt;p&gt;Though some people think of the configuration process of an ORM as a pain point, I have loved the ease with which I can configure different databases for different environments using a consistent interface.&lt;/p&gt;

&lt;p&gt;I have greatly enjoyed using an ORM. As a full-stack developer working on small teams where we don’t have a dedicated database guru, it has greatly simplified working with the data layer.&lt;/p&gt;

&lt;p&gt;Overall, I prefer working with an ORM to not. That being said, I haven’t had to work at the scale where SQL tuning becomes more important, so I’m sure my opinion is very biased.&lt;/p&gt;

&lt;p&gt;If you haven’t tried using one, I would suggest trying it out and seeing how it works for your development system, but ultimately somebody who is really strong with databases will always give you better performance than the best ORM system.&lt;/p&gt;

&lt;p&gt;I hope that you have learned something new today! I would appreciate it if you could drop some 👏 or leave a comment below! Also, this is my first post ever, don't bite me if you come across stuff that's displeasing to you :) .&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
