<?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: Andrew</title>
    <description>The latest articles on Forem by Andrew (@ajkachnic).</description>
    <link>https://forem.com/ajkachnic</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%2F224061%2Fd663709d-328e-483a-8516-67e809486192.png</url>
      <title>Forem: Andrew</title>
      <link>https://forem.com/ajkachnic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ajkachnic"/>
    <language>en</language>
    <item>
      <title>Towards a Better Developer Experience</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Sun, 31 Jan 2021 14:48:18 +0000</pubDate>
      <link>https://forem.com/ajkachnic/towards-a-better-developer-experience-3alj</link>
      <guid>https://forem.com/ajkachnic/towards-a-better-developer-experience-3alj</guid>
      <description>&lt;p&gt;Despite the many Twitter arguments that I've gotten into, many developers still feel that developer experience isn't important. Hell, that's probably the reason that PHP still exists in the wild. Cheap jabs at PHP aside, I feel that a good developer experience is important for a myriad of reasons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does it matter?
&lt;/h2&gt;

&lt;p&gt;To address this, I'd like to provide an example, and you'll hopefully see where I'm going with this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Imagine you're working on a fairly large React project, and you have to update some styles for a component. Each change you make takes a second or two to update, but it's no problem for a 10x developer like yourself. You can just try to make large changes all at once and deal with it. Finally, you're ready to run a test build, and oh, wait for it... wait for it... it's still not done? You go and get yourself a cup of coffee and check in on it, and it's still going. You go take your dog for a walk, and... it's still going. You go walk your dog again (even your dog is tired of webpack at this point), and oh, wait, the process crashed. You then scream a variety of curse words while sipping cold coffee.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;See, wasn't that a fun adventure? No? Did it hit a little too close to home? Here's a virtual tissue to wipe your tears. Although the example was a bit of an exaggeration, it wasn't too far off. So to give a serious point for once, developer experience affects productivity; happiness; and overall how much you enjoy working on something (crazy, right?). So, if there are simple ways to improve this experience, why not go for it?&lt;/p&gt;

&lt;h2&gt;
  
  
  Effect on new developers
&lt;/h2&gt;

&lt;p&gt;I think it would be a good idea to take a moment to discuss the effect that developer experience can have on people who are just learning to write code. We've all been there at one time or another, and it can become really overwhelming (especially in the JavaScript ecosystem) to be bombarded by a million new tools, concepts, and technologies. A positive experience in the tooling department can really make all the difference in the world. No one wants to make a cup of coffee every time they add a new variable to their code (that would be a lot of coffee). I really do believe that a good developer experience can draw newcomers in, and a bad one can push them away.&lt;/p&gt;

&lt;h2&gt;
  
  
  What makes a good developer experience
&lt;/h2&gt;

&lt;p&gt;I &lt;strong&gt;&lt;em&gt;could&lt;/em&gt;&lt;/strong&gt; list a million little regurgitated ideas of what makes a developer experience great, but let's be honest. I don't like writing enough to enjoy that, and you don't really want to read that. That would be a &lt;strong&gt;bad experience&lt;/strong&gt;, which, as you've probably figured out, is a big no-no in this article. So to keep this short, a few things that make the developer experience better are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performance: Everyone loves snappy things. Well I mean languages like Python and Ruby are out there, so maybe not everyone. But most people like speed&lt;/li&gt;
&lt;li&gt;Reliability: It can be really frustrating when a tool works one minute, but then refuses to work the next day because the lunar cycle changed. Tools should be reliable&lt;/li&gt;
&lt;li&gt;Ease of use: While not everything has to be simple, a tool that makes things easier on developers is always appreciated - why do you think package managers exist?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is, as always, not a complete list, but rather some of the main ideas. There's a lot more complexity here that I am neither qualified nor desiring to talk about. Note, these are the same principles for good UX (at least I think they are), and for good reason. At the simplest level, developers are users of tools and hence want those same things (although I doubt your average user could learn how to use VIM). If you take one thing away from this, let it be this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Developer experience and user experience don't have to be mutually exclusive (that's a lie perpetrated by the dark forces of Stackoverflow)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  An overview of some great tools
&lt;/h2&gt;

&lt;p&gt;I was originally planning on making this whole post into a list of tools for a good developer experience, but:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;That makes absolutely no sense without any context&lt;/li&gt;
&lt;li&gt;I'm also not a fan of writing list articles (listicles) as they come off as low effort, and possibly boring if not executed right&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So instead of giving you a laundry list of tools that you must use if you to want to be an ex-Google, ex-Facebook, ex-millionaire, ex-ecutioner, I'll showcase a few tools that really have changed my workflow for the better, as a way to exemplify what I'm talking about.&lt;/p&gt;

&lt;p&gt;Two tools, in particular, came to mind (well really three, but you'll see what I mean)&lt;/p&gt;

&lt;h3&gt;
  
  
  Snowpack / ESBuild
&lt;/h3&gt;

&lt;p&gt;I'm including these two together because I have yet to use esbuild on its own, however, it's an integral part of snowpack and what makes it great. I won't go into detail about snowpack - as &lt;a href="https://snowpack.dev"&gt;their website&lt;/a&gt; does a much better job at it. However, I will say the techniques are genius and it results in ridiculously fast build times. Seriously, if you use React or Svelte (or even if you don't), give Snowpack a try!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;pnpm&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;On the surface, &lt;code&gt;pnpm&lt;/code&gt; is just a drop-in replacement for &lt;code&gt;npm&lt;/code&gt;. However, in reality, it is... well yeah it's just another &lt;code&gt;npm&lt;/code&gt; replacement. But it's a really fast &lt;code&gt;npm&lt;/code&gt; replacement! That must get it to some level of coolness. &lt;code&gt;pnpm&lt;/code&gt; uses a global cache of your node modules and uses smart directory structuring. In other words, it's like yarn, but better. Try it out &lt;a href="https://pnpm.js.org"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing remarks
&lt;/h2&gt;

&lt;p&gt;As is usual with my rather unprofessional writing, this post has a big fat &lt;code&gt;/s&lt;/code&gt; attached to it. If I insulted your programming language of choice, then you might want to learn JavaScript or Rust instead. Seriously though, thanks for putting up with my bad jokes for long enough to get through the post. I figure there was a lot of "Just get on with it already"-ing, and I thank you for it.&lt;/p&gt;

&lt;p&gt;I loved watching myself slowing losing my sanity, and this article going increasingly off the rails. Thanks for reading, and come back next time to see me complain some-more (shhh &lt;code&gt;complaining == passion&lt;/code&gt; when type coercion is on)&lt;/p&gt;

&lt;h3&gt;
  
  
  Credits
&lt;/h3&gt;

&lt;p&gt;Cover Photo by &lt;a href="https://unsplash.com/@gentlestache?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Bonneval Sebastien&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/user-experience?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/su_andrewk"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ajkachnic"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tooling</category>
      <category>javascript</category>
    </item>
    <item>
      <title>One Bash Alias That Makes Life Easier</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Thu, 30 Apr 2020 22:08:09 +0000</pubDate>
      <link>https://forem.com/ajkachnic/one-bash-alias-that-makes-life-easier-1k0n</link>
      <guid>https://forem.com/ajkachnic/one-bash-alias-that-makes-life-easier-1k0n</guid>
      <description>&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To set environment variables persistently, you normally have to add it to your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.profile&lt;/code&gt;. However, this can be annoying, and often more trouble than it's worth. An alternative is writing a function in your &lt;code&gt;.bashrc&lt;/code&gt; that appends to a global &lt;code&gt;.env&lt;/code&gt; file, and sourcing that file in your &lt;code&gt;.bashrc&lt;/code&gt;. I'll show the code and then break it down&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;setenv&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.env
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="nv"&gt;$FILE&lt;/span&gt;
    &lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="nv"&gt;$FILE&lt;/span&gt;
  &lt;span class="k"&gt;fi
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$FILE&lt;/span&gt;
  &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.env &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Code Breakdown
&lt;/h2&gt;

&lt;p&gt;The first line of the function sets the file variable to a &lt;code&gt;.env&lt;/code&gt; in the user's home directory. The &lt;code&gt;if&lt;/code&gt; statement checks if the file doesn't exist, and if it doesn't, then it creates the file and sources it. The &lt;code&gt;echo&lt;/code&gt; command appends to the &lt;code&gt;.env&lt;/code&gt; file with the first and second arguments. The &lt;code&gt;export&lt;/code&gt; command makes the environmental variable available right after running the command.&lt;/p&gt;

&lt;p&gt;Finally, the last line sources the file, but only if it exists &lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;You could then run something like this in your terminal (after reopening it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;setenv WORKING hopefully
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the general syntax for the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;setenv &amp;lt;key&amp;gt; &amp;lt;value&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: If you refine a variable, 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;setenv WORKING &lt;span class="nb"&gt;false
&lt;/span&gt;setenv WORKING &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the file will include both of these, but the first will be unused.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping things up
&lt;/h2&gt;

&lt;p&gt;I use many other aliases and functions, but this is one that I recently thought of, and it is very useful.&lt;/p&gt;

&lt;p&gt;Thanks for reading 🎉&lt;/p&gt;

</description>
      <category>bash</category>
    </item>
    <item>
      <title>My Results with 100 Days 100 Projects</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Tue, 07 Apr 2020 14:13:17 +0000</pubDate>
      <link>https://forem.com/ajkachnic/my-results-with-100-days-100-projects-5g50</link>
      <guid>https://forem.com/ajkachnic/my-results-with-100-days-100-projects-5g50</guid>
      <description>&lt;p&gt;A few days ago, I finished the &lt;a href="https://www.florin-pop.com/blog/2019/09/100-days-100-projects/"&gt;100days100projects&lt;/a&gt; challenges, started by &lt;a href="https://twitter.com/florinpop1705"&gt;Florin Pop&lt;/a&gt;. I originally intended to do it for 30 days, but I just kept going.&lt;/p&gt;

&lt;p&gt;Throughout the challenge, I drew some conclusions and found some resources that helped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some Conclusions
&lt;/h2&gt;

&lt;p&gt;I found that when I was making projects, it was easier to either focus on a nice, clean UI or a functional project. Most times, it was either one or the other.&lt;/p&gt;

&lt;p&gt;For most of them, I got right into the programming rather than designing them beforehand. This allowed me to quickly develop the site, instead of focusing on the design.&lt;/p&gt;

&lt;p&gt;Finally, I found that I was able to do these projects fairly quickly when I focused on good design or good functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and Tricks
&lt;/h2&gt;

&lt;p&gt;The most helpful tip I can give is making a boilerplate code snippet. Something that setups up your fonts, CSS variables (custom properties), and basic HTML structure. Here is an example&lt;/p&gt;

&lt;p&gt;&lt;code&gt;index.html&lt;/code&gt; -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"X-UA-Compatible"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"ie=edge"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Template&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"content"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"index.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;style.scss&lt;/code&gt; -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;*,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&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="nl"&gt;margin&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="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#1187fc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--dark&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--neutral&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#151515&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.125em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--neutral&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;overflow-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.content&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--light&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;70vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;3em&lt;/span&gt; &lt;span class="n"&gt;rgba&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;0&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;.15&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;&lt;a href="https://snippet-generator.app/"&gt;This snipper generator&lt;/a&gt; should help you out with this&lt;/p&gt;

&lt;p&gt;Setting up templates allows you to get out of the repetitive setup and into the actual programming&lt;/p&gt;

&lt;p&gt;My second tip is to try to be distraction-free while working on the project. You will be much more focused if you are away from distractions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.florin-pop.com/blog/2019/09/100-days-100-projects/"&gt;Florin Pop's list&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://collectui.com/"&gt;CollectUI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dribbble.com/"&gt;Dribbble&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to"&gt;dev.to&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these gave me inspiration on my journey. Later on in the challenge, one of the biggest bits of help was CollectUI's navigation section (the list of types of projects). It helped a lot when I was out of ideas.&lt;/p&gt;

&lt;p&gt;Also, just looking up project ideas can &lt;strong&gt;&lt;em&gt;sometimes&lt;/em&gt;&lt;/strong&gt; yield great results. It just depends on what you search and how deeply you look.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;For me personally, I'm gonna take a 1-2 break from challenges. Afterward, I will probably try out &lt;a href="https://1productaweek.com/"&gt;1 Product a Week&lt;/a&gt; or &lt;a href="https://levels.io/12-startups-12-months/"&gt;12 Startups in 12 Months&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm going to continue programming every day that I can and working hard to improve my skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Things Up
&lt;/h2&gt;

&lt;p&gt;If you read this, thank you for your time ❤️. If you got to this point and you are debating whether you should try the challenge, try it. You can start with a shorter time and if you like it, extend it. &lt;/p&gt;

&lt;p&gt;I hope you enjoyed reading this as much as I enjoy writing it. Please like and comment if you did enjoy, this article was 100 days in the making.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social Media&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/su_andrewk"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ajkachnic"&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andrewkachnic.now.sh"&gt;My Website&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>100days100projects</category>
    </item>
    <item>
      <title>My Take on Atomic Design in React</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Sat, 28 Mar 2020 23:14:35 +0000</pubDate>
      <link>https://forem.com/ajkachnic/my-take-on-atomic-design-in-react-2dmf</link>
      <guid>https://forem.com/ajkachnic/my-take-on-atomic-design-in-react-2dmf</guid>
      <description>&lt;p&gt;For around a week, I have been working on a side project, and I am currently working on the frontend of it. &lt;a href="https://dev.to/ajkachnic/my-experience-with-atomize-and-next-js-4e9d"&gt;I previously used Atomize&lt;/a&gt; as a UI framework, on other projects. But, I still prefer the freedom of creating my own components&lt;/p&gt;

&lt;p&gt;One thing I did like about &lt;a href="https://atomizecode.com"&gt;Atomize&lt;/a&gt; was that it employed &lt;a href="https://bradfrost.com/blog/post/atomic-web-design/"&gt;Atomic Design&lt;/a&gt;, hence the name. If you don't know what Atomic Design is, here is a summary from their website&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Atomic design is methodology for creating design systems. There are five distinct levels in atomic design:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Atoms&lt;/li&gt;
&lt;li&gt;Molecules&lt;/li&gt;
&lt;li&gt;Organisms&lt;/li&gt;
&lt;li&gt;Templates&lt;/li&gt;
&lt;li&gt;Pages&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;Fundamentally, as you go up this tree, the components get more complex. Molecules are made up of Atoms, Organisms are made up of Molecules and so on.&lt;/p&gt;

&lt;p&gt;It's worth noting that for this project, I am using Next.js on top of React.&lt;/p&gt;

&lt;p&gt;So for that reason, I will be focusing solely on the &lt;code&gt;component&lt;/code&gt; directory and not involving other folders. This is to simplify it and make it more universal.&lt;/p&gt;

&lt;p&gt;Here is what a normal React components folder may look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- components
  - button.jsx
  - title.jsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There would be more components, maybe they would be within their folders, but the point remains the same. The components are all together and not organized. That is okay as long as they are consistent. &lt;/p&gt;

&lt;p&gt;However, "okay" doesn't have to be the standard. We can do better than "okay".&lt;/p&gt;

&lt;p&gt;This is what a more complex file system looks like, using normal component structuring. After that, there is the same structure, but using Atomic Design.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Normal
- components
  - Button
    - index.jsx
  - Title
    - index.jsx
  - Hero
    - index.jsx
  - Navbar
    - index.jsx
  - Dropdown
    - index.jsx

// Atomic
- components
  - atoms
    - Button
      - index.jsx
    - Title
      - index.jsx
  - molecules
    - Dropdown
      - index.jsx
  - organisms
    - Hero
      - index.jsx
    - Navbar
      - index.jsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, at least to me, I like the extra organization of these components. But, there is more to Atomic Design then moving some folders. The meat and potatoes of this strategy is making modular components and having them depend on each other.&lt;/p&gt;

&lt;p&gt;For example, instead of using an &lt;code&gt;h1&lt;/code&gt; element in your hero section, build a component for a Title and use it throughout your project. Components at higher levels should rely on lower components, whenever possible.&lt;/p&gt;

&lt;p&gt;So, your Hero section might use a Title, a Body text, and a Button component. &lt;/p&gt;

&lt;p&gt;One of the best benefits of using Atomic Design is that the site should consistent, with components remaining similar throughout the website. This is extremely important in larger projects, with multiple developers. &lt;/p&gt;

&lt;p&gt;Another good thing about using this technique is that it is easier to get accommodated. If I am starting contributing to some open source project, it is much easier for me to understand it if the project includes a basic structure. I would almost have an entry point to the project, either by looking at the Atoms or the Pages. The Atoms show a lot of the underlying code, and the Pages offer a higher-level view of the project, from which I can dive into the components.&lt;/p&gt;

&lt;p&gt;I think that Atomic Design is worth serious consideration, especially if the project has a scattered and inconsistent code-base.&lt;/p&gt;

&lt;h1&gt;
  
  
  What to take from this
&lt;/h1&gt;

&lt;p&gt;I think that even if you don't implement Atomic Design (it's not for everyone), I think you should try to be aware of how you are structuring your components and keeping consistency, both within structure and design.&lt;/p&gt;

&lt;p&gt;Thanks for reading ❤️. I hope you enjoyed it. I appreciate all feedback and suggestions. If you have any ideas for anything you think I should cover, feel free to let me know.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social Media&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/su_andrewk"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ajkachnic"&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andrewkachnic.now.sh"&gt;My Website&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>design</category>
      <category>javascript</category>
    </item>
    <item>
      <title>User Authentication, In 2020</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Wed, 25 Mar 2020 15:55:28 +0000</pubDate>
      <link>https://forem.com/ajkachnic/user-authentication-in-2020-1n53</link>
      <guid>https://forem.com/ajkachnic/user-authentication-in-2020-1n53</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In 2020, for many startups, side projects, and companies, using prebuilt authentication systems the likes of Firebase, Authpack, and Auth0 can be more secure and efficient than building out their own system.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And if you think about it, it makes sense. It's not like every company writes their own JavaScript framework. Why should companies reinvent the wheel?&lt;/p&gt;

&lt;p&gt;With that said, in this article, we will be exploring a few different options and categories for authentication.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
Prebuilt traditional authentication

&lt;ul&gt;
&lt;li&gt;My recommendations&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Password-less authentication

&lt;ul&gt;
&lt;li&gt;My Recommendations&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Social Login

&lt;ul&gt;
&lt;li&gt;My recommendations&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Implementing your own

&lt;ul&gt;
&lt;li&gt;My recommendations&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So without further ado, let's get started&lt;/p&gt;

&lt;h1&gt;
  
  
  Prebuilt traditional authentication
&lt;/h1&gt;

&lt;p&gt;So this is the old-fashioned standard that most sites are using. The site usually requires a username or an email and a password.&lt;/p&gt;

&lt;p&gt;While this is the most common setup, I would argue that it can lead to lower security compared to password-less standards.&lt;br&gt;
A cryptographically secure randomly generated code is much harder to guess than your average password.&lt;/p&gt;

&lt;p&gt;But, many users prefer this method because it is what they are used to. The most popular option isn't always the best, but traditional authentication has the advantage of being well-known and recognized. Everyone and their mother understands the concepts of it, mostly because it isn't rooted in a mysterious technology. Going the conventional route allows users to be accustomed to your platform from the beginning.&lt;/p&gt;

&lt;p&gt;So, if you don't wanna spend one of your innovation tokens (&lt;a href="https://mcfunley.com/choose-boring-technology"&gt;read this&lt;/a&gt;) or prefer familiarity with your user base, then this may be the way to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  My recommendations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://authpack.io"&gt;Authpack&lt;/a&gt;:
&lt;strong&gt;Extremely&lt;/strong&gt; generous free tier with unlimited users. Great support and documentation. Stripe payments also integrated. Incredible user experience&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://auth0.com/"&gt;Auth0&lt;/a&gt;: Has a more enterprise-focused angle. Free plan with 7000 active users&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://firebase.google.com/docs/auth/"&gt;Firebase Auth&lt;/a&gt;: Part of Firebase. Includes many other options including anonymous, social login, and Phone Auth. Phone Auth limited to 10k for free&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Password-less authentication
&lt;/h1&gt;

&lt;p&gt;Recently, a few companies have begun offering password-less as a less risky alternative to traditional authentication.&lt;/p&gt;

&lt;p&gt;These use public-private encryption algorithms to generate key pairs. The public key is saved to a database associated with another piece of data, often an email or phone number. Then, a “challenge” is sent, and the browser uses the private key to solve. The server sends a unique token to the browser and the transaction is over. &lt;a href="https://did.app/articles/how-did-works"&gt;Read about this more from one of the providers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I reached out to &lt;a href="https://did.app"&gt;DID.app&lt;/a&gt; for a one -sentence summary, and this is what they said.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;DID.app is an Identity Provider, that authenticates users by verifying access to either an email address or securely stored private key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Security is greatly improved by this process and the user experience may also be better, but only when they've gotten used to it. If you want to try a new, promising technology, password-less may be the route to go down.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Recommendations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://did.app"&gt;DID&lt;/a&gt;: 1,000 users. Unlimited applications. Reasonably priced and very open about the technology&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://auth0.com/"&gt;Auth0&lt;/a&gt;: Enterprise-facing. Has support for password-less (obviously)&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Social Login
&lt;/h1&gt;

&lt;p&gt;This seems to be a perfect solution for both users and companies. Users get a much quicker registration process and companies barely have to manage their authentication or paying for it.&lt;/p&gt;

&lt;p&gt;These usually rely on the 0Auth standard to authorize the Application&lt;/p&gt;

&lt;p&gt;Social login can also end up allowing some great concoctions, such as &lt;a href="https://soa.ai"&gt;SOA (Son of Anton)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can implement these yourself fairly easily using &lt;a href="https://passportjs.org"&gt;passport&lt;/a&gt; (which is sponsored by Auth0) and Express or use one of these platforms. Implementing your own solution with passport is relatively safe, and gives you the flexibility of adding pretty much any social provider. If you need an integration with a lesser-known service, this may be your only feasible option.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Recommendations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://authpack.io"&gt;Authpack&lt;/a&gt;: Only four options currently (Google, Facebook, Slack, Github), but the creator is open to adding new ones upon request. Same features mentioned earlier&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://firebase.google.com/docs/auth/"&gt;Firebase Auth&lt;/a&gt;: Many providers supported, but most likely harder to get one added&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://auth0.com/"&gt;Auth0&lt;/a&gt;: Unclear what social login providers are supported. Sign in with Google supported&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Implementing your own
&lt;/h1&gt;

&lt;p&gt;Building your own authentication system for production is not recommended. There are many security risks involved in doing this. Let's just say it's not a task for the faint of heart.&lt;/p&gt;

&lt;p&gt;If you do want to attempt this challenge, assume you will be hacked. It's not a matter of if, it is a matter of when and how.&lt;/p&gt;

&lt;p&gt;A strong understanding of security on the web should be possessed if you are going down this route. Knowledge of hashing functions, encryption, SSL and TLS, Sessions, and much more is essential.&lt;/p&gt;

&lt;p&gt;I recommend using &lt;a href="https://expressjs.com/"&gt;Express&lt;/a&gt; as a server, &lt;a href="https://passportjs.org"&gt;passport&lt;/a&gt; and &lt;a href="http://www.passportjs.org/packages/passport-local/"&gt;passport-local&lt;/a&gt;, and &lt;a href="https://github.com/helmetjs/helmet"&gt;helmet&lt;/a&gt; for some added security.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication"&gt;The definitive guide to form-based authentication&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cheatsheetseries.owasp.org/"&gt;These OWASP cheat sheets should also help&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Wrapping things up
&lt;/h1&gt;

&lt;p&gt;My #1 recommendations for Auth are &lt;a href="https://authpack.io"&gt;Authpack&lt;/a&gt; and &lt;a href="https://did.app"&gt;DID.app&lt;/a&gt;. They both are extremely well-thought-out services that are quite useful within their categories.&lt;/p&gt;

&lt;p&gt;I hope you enjoyed this article. I spend a lot of time writing it and I appreciate any feedback or suggestions. If you would like me to write an article about implementing any of these services, please let me know.&lt;/p&gt;

&lt;p&gt;Thank you for reading, and remember, &lt;strong&gt;hash your passwords!&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Updates
&lt;/h1&gt;

&lt;p&gt;I just discovered &lt;a href="https://magic.link/"&gt;Magic&lt;/a&gt;. It is a link-based password-less authentication service. It might be worth consideration.&lt;/p&gt;

</description>
      <category>security</category>
      <category>privacy</category>
    </item>
    <item>
      <title> Make a simple HTTP Server with Node in 6 Steps</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Thu, 05 Mar 2020 23:56:47 +0000</pubDate>
      <link>https://forem.com/ajkachnic/make-a-simple-http-server-with-node-in-6-steps-491c</link>
      <guid>https://forem.com/ajkachnic/make-a-simple-http-server-with-node-in-6-steps-491c</guid>
      <description>&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;This post was originally written for Twitter&lt;/em&gt;&lt;br&gt;
^ You can find the original &lt;a href="https://twitter.com/su_andrewk/status/1235717546827018241"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Initialize the project
&lt;/h2&gt;

&lt;p&gt;Follow the prompts from this command&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;touch &lt;/span&gt;index.js

npm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. The basics
&lt;/h2&gt;

&lt;p&gt;Here is the basic layout of the server&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="c1"&gt;// Import the HTTP module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Make our HTTP server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Have the server listen on port 9000&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Routing
&lt;/h2&gt;

&lt;p&gt;Routing can be done by importing the builtin URL Module and parsing the request URL. Then, we compare the request URL to the URL for the route&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="c1"&gt;// Import the HTTP module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Import the URL module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Make our HTTP server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// Parse the request url&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;you're boring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="c1"&gt;// Have the server listen on port 9000&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Methods
&lt;/h2&gt;

&lt;p&gt;Similar to routes, we can check the method of the request and compare it the expected result&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="c1"&gt;// Import the HTTP module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Import the URL module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Make our HTTP server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// Parse the request url&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;
    &lt;span class="c1"&gt;// Compare our request method&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GET&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;you're boring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// Have the server listen on port 9000&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Headers
&lt;/h2&gt;

&lt;p&gt;We can set headers on the response pretty easily using &lt;code&gt;res.setHeader()&lt;/code&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="c1"&gt;// Import the HTTP module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Import the URL module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Make our HTTP server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// Set our header&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Access-Control-Allow-Origin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Parse the request url&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;
    &lt;span class="c1"&gt;// Compare our request method&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GET&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;you're boring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// Have the server listen on port 9000&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Request Parameters
&lt;/h2&gt;

&lt;p&gt;We can easily grab our URL based query strings with a little modification&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="c1"&gt;// Import the HTTP module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Import the URL module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Make our HTTP server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// Set our header&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Access-Control-Allow-Origin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Parse the request url&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the path from the parsed URL&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;
    &lt;span class="c1"&gt;// Compare our request method&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GET&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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="c1"&gt;// Send a JSON version of our URL query&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, you sent&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reqUrl&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&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="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// Have the server listen on port 9000&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping things up
&lt;/h2&gt;

&lt;p&gt;I hope you enjoyed the quick tutorial. I did most of the research for this while developing my own HTTP framework, called &lt;code&gt;onlinx&lt;/code&gt;, built lightning fast and fully dependency-less. If you have any questions, feel free to comment them. If you are interested in &lt;code&gt;onlinx&lt;/code&gt; please let me know. Thank you for reading and goodbye.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>My Experience with Atomize and Next.js</title>
      <dc:creator>Andrew</dc:creator>
      <pubDate>Mon, 24 Feb 2020 00:41:10 +0000</pubDate>
      <link>https://forem.com/ajkachnic/my-experience-with-atomize-and-next-js-4e9d</link>
      <guid>https://forem.com/ajkachnic/my-experience-with-atomize-and-next-js-4e9d</guid>
      <description>&lt;p&gt;I started out on my journey to redesign my portfolio website a few months ago. I created many designs, just to question it and make another. Eventually, I hit the jackpot with a prototype and decided it was time to realize it. &lt;/p&gt;

&lt;p&gt;After hearing great things about it, I also decided to host the website on &lt;a href="https://zeit.co"&gt;Zeit.co&lt;/a&gt;. So, before I started coding, I was scrolling through &lt;a href="https://www.producthunt.com/"&gt;Product Hunt&lt;/a&gt; and I saw &lt;a href="https://www.producthunt.com/posts/atomize-react"&gt;Atomize React&lt;/a&gt;. It immediately intrigued me, so I went to their homepage and got more information.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Atomize React is a UI framework that helps developers collaborate with designers and build consistent user interfaces effortlessly" - &lt;a href="https://atomizecode.com"&gt;Atomize React&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I went into the quick start and well, got started. After having to setup the Styletron engine for next.js (the framework I decided on), I was already a little worried. But my doubts quickly faded away as I used Atomize, or at least some of my doubts. For example, the framework itself worked well, but it felt difficult to get into the Atomic Design approach and they didn't really do too much to help. Also, the attributes to style the Components were so strange that I was pretty much glued to the documentation. There were a few other issues, but most of them are just little problems.&lt;/p&gt;

&lt;p&gt;So, I built out the site, component by component, consulting the documentation regularly. This went fine and I published the site within 2 days of starting. However, after publishing the site, I realized a few issues that I hadn't thought of. One was the max width of the container. On different sizes, the &lt;code&gt;&amp;lt;Container&amp;gt;&lt;/code&gt; element had a max width. This caused the container to be only half of my screen width. Another problem was that my row was configured strangely, so an &lt;code&gt;&amp;lt;Image&amp;gt;&lt;/code&gt; and a &lt;code&gt;&amp;lt;Text&amp;gt;&lt;/code&gt; tag weren't on the same line as they should've been.&lt;/p&gt;

&lt;p&gt;My last big issue was kind of on me for bad implementation. After releasing the site and fixing everything else, I started working on adding a dark mode. At first, I passed the background and color of each component as a Stateful variable. Then, when I wanted to toggle dark mode, I could just change the state and it would update. However, it was extremely messy and dirty code. I also had trouble deploying the code, so I rolled back the commit and started again.&lt;/p&gt;

&lt;p&gt;This time, however, it went much better. I took a different approach, utilizing the Styletron engine and the &lt;code&gt;useState()&lt;/code&gt; hook, located in my &lt;code&gt;index.js&lt;/code&gt; file. I then passed the variable to set the state to my &lt;code&gt;App.js&lt;/code&gt; as a prop. The state variable was used to append custom colors to my Styletron Config. Basically, you can set custom colors and variables to use in the attributes of your components, and I changed the custom colors to match dark mode or light mode. This worked and resulted in much cleaner code.&lt;/p&gt;

&lt;p&gt;Overall, my experience was pretty good. It had it's road bumps, but the issues were small and very manageable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ratings
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt; - 8/10&lt;br&gt;
&lt;a href="https://atomizecode.com"&gt;Atomize React&lt;/a&gt; - 8/10&lt;br&gt;
&lt;a href="https://zeit.co"&gt;Zeit.co&lt;/a&gt; - 10/10&lt;/p&gt;

&lt;p&gt;If you read all the way through this, thanks for reading. &lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ajkachnic.now.sh"&gt;The final site&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ajkachnic/portfolio"&gt;The Github&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Updates
&lt;/h2&gt;

&lt;p&gt;I rebuilt the site without using any component library, mostly because maintenance was extremely annoying &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
