<?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>DEV Community: Sarah</title>
    <description>The latest articles on DEV Community by Sarah (@sarahk).</description>
    <link>https://dev.to/sarahk</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%2F353115%2F83a8678e-6374-46a3-9d42-3a1d65ed3966.png</url>
      <title>DEV Community: Sarah</title>
      <link>https://dev.to/sarahk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sarahk"/>
    <language>en</language>
    <item>
      <title>What does Full Stack mean to you?</title>
      <dc:creator>Sarah</dc:creator>
      <pubDate>Sat, 02 May 2020 10:25:10 +0000</pubDate>
      <link>https://dev.to/sarahk/what-does-full-stack-mean-to-you-4fj5</link>
      <guid>https://dev.to/sarahk/what-does-full-stack-mean-to-you-4fj5</guid>
      <description>&lt;p&gt;I've seen many different flavours of what companies think a Full Stack role includes, here are a few I've seen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frontend, Backend&lt;/li&gt;
&lt;li&gt;Frontend, Backend, DBA&lt;/li&gt;
&lt;li&gt;Frontend, Backend, UX, Mobile&lt;/li&gt;
&lt;li&gt;Frontend, Backend, DBA, DevOps&lt;/li&gt;
&lt;li&gt;Frontend, Backend, DBA, DevOps, QA, Business Analyst&lt;/li&gt;
&lt;li&gt;and the list goes on...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What do you think a Full Stack Developers responsibilities are? Does it need some uniformity or is it ok to have different flavors?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>career</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Top tips on Node Express (for Java Developers)</title>
      <dc:creator>Sarah</dc:creator>
      <pubDate>Fri, 10 Apr 2020 19:12:06 +0000</pubDate>
      <link>https://dev.to/sarahk/top-tips-on-node-express-for-java-developers-341c</link>
      <guid>https://dev.to/sarahk/top-tips-on-node-express-for-java-developers-341c</guid>
      <description>&lt;p&gt;Sometimes learning a new language and stack can seem so alien, well at least it did to me. You know that programming in any paradigm is generally the same and all the rest is just syntactic sugar but it's hard to really see past that at first; especially when StackOverflow doesn't have the answers you're looking for. &lt;/p&gt;

&lt;p&gt;Luckily, I've written a beginners guide on Node Express for you guys. I got you. If you're dabbling into new territories, looking into something new or changing stacks for a new project this blog is a sanity check for all you Java developers. So, let's get into it! &lt;br&gt;
&lt;strong&gt;Disclaimer:&lt;/strong&gt; I am not a Node.js expert but I learnt the hard way so you don't have to 🙇🏻‍♀️&lt;/p&gt;

&lt;p&gt;This is a long read, here are the contents - jump ahead:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
 🤔 Why node? 
How Node works 101. Useful information to determine if Node is for your project by diving into the V8 Engine.&lt;/li&gt;
&lt;li&gt;
📦 Library package management, build management, tasks and versioning  What is npm and how to get started&lt;/li&gt;
&lt;li&gt;
🖋 JavaScript nice to knows
Truthy, falsy, promises, variable declarations, function/class scope, functional programming, ESLint, logging and libraries&lt;/li&gt;
&lt;li&gt;
📥📤 Node Express 
Architecture, folder structure, secrets and configs, middleware, ORM&lt;/li&gt;
&lt;li&gt;
⌨️ TypeScript vs JavaScript I'll let you decide&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;
  
  
  🤔 Why Node? Is it for you? Here are some things to consider...
&lt;/h1&gt;

&lt;p&gt;Node (officially known as Node.js) has been a buzzword in the tech scene for a long while now. It seems like it's not going anywhere anytime soon either, so why Node? &lt;/p&gt;

&lt;p&gt;Node is server-side JavaScript runtime built on using Chrome's V8 JavaScript Engine and it's key attraction is that its non-blocking I/O. I know... non-blocking who? Well, this will determine if Node is right for your project. In my opinion it either is or it isn't there are no in-betweens (marmite vibes).&lt;/p&gt;

&lt;p&gt;The V8 runtime engine is single threaded and it uses an &lt;em&gt;event loop&lt;/em&gt; to execute events in the queue. In Java the thread queue has a number of tasks awaiting execution by a thread pool right? In this case an event is a task and an event loop is the execution engine.&lt;/p&gt;

&lt;p&gt;So what about asynchronous events, like making an API request? Does the event loop wait for the API to return? If it does latency would be an issue in a single thread. To get around this asynchronous events use callbacks. &lt;/p&gt;

&lt;p&gt;A callback event that is added to the back of the queue with the asynchronous response. Now other events can be executed in the meantime and there's no waiting around, hence &lt;em&gt;'non-blocking I/O'&lt;/em&gt; 😉&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvcuhdkxxnjitph21azt3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvcuhdkxxnjitph21azt3.png" alt="Express loop diagram author sarah ksiyer" width="800" height="324"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Disclaimer2:&lt;/strong&gt; I made an error in this diagram, task is meant to read 'event'&lt;/p&gt;

&lt;p&gt;For this reason, Node can &lt;em&gt;&lt;strong&gt;perform faster&lt;/strong&gt;&lt;/em&gt; for event-driven uses, like web servers, real-time server (that use web sockets for example), CRUD heavy apps and API's.&lt;/p&gt;

&lt;p&gt;Also for this reason, Node &lt;strong&gt;&lt;em&gt;doesn't perform so well&lt;/em&gt;&lt;/strong&gt; on processive intensive tasks, data calculations and blocking operations.&lt;/p&gt;

&lt;p&gt;Beyond the runtime, Node uses JavaScript and benefits from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JS doesn't have a compiler so it inherently has less constraints&lt;/li&gt;
&lt;li&gt;it has a flexible model which is really useful when using NoSQL &lt;/li&gt;
&lt;li&gt;its platform independent (then again so is Java, so JS doesn't win any brownie points here)&lt;/li&gt;
&lt;li&gt;you can use the same language on the server-side as you do on the client-side, great for those working on the full stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we know what Node is, when we should use it and what the runtime brings we can get into package/build management, JavaScript basics, Node Express architecture and TypeScript.&lt;/p&gt;
&lt;h1&gt;
  
  
  📦 Library package/build management, tasks and versioning
&lt;/h1&gt;

&lt;p&gt;If you're familiar with npm you may want to jump ahead to the next section.&lt;/p&gt;

&lt;p&gt;npm is comparable to Maven and Gradle. &lt;a href="http://npmjs.com" rel="noopener noreferrer"&gt;npmjs.com&lt;/a&gt; is an online catalog of JavaScript Libraries. npm (Nodes Package Manager) manages dependencies, package information and run tasks (like build, start or run tests). &lt;/p&gt;

&lt;p&gt;To use npm, you would need to install both node and npm and use it through its CLI. Get started &lt;a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Each npm project has a &lt;strong&gt;package.json&lt;/strong&gt; in the root project folder. This file defines the &lt;em&gt;project name, version, author, description, license, dependencies&lt;/em&gt; and much more. Project dependencies are downloaded into the root &lt;strong&gt;node_modules&lt;/strong&gt; folder.&lt;/p&gt;
&lt;h3&gt;
  
  
  Dependencies
&lt;/h3&gt;

&lt;p&gt;There are two types of dependencies, project dependency and devDependencies which is only required in development. For example a library CLI may only be required for developers, perhaps? I would compare this aspect of npm to Maven.&lt;/p&gt;
&lt;h3&gt;
  
  
  Tasks
&lt;/h3&gt;

&lt;p&gt;Typically your node application you should have at least a start, test and build tasks - but you can have as many as you'd like. These would be run by your continuous integration pipeline I would compare this aspect of npm to Gradle.&lt;/p&gt;
&lt;h1&gt;
  
  
  🖋JavaScript nice to knows
&lt;/h1&gt;

&lt;p&gt;If you're familiar with JavaScript you may want to jump ahead to the next section.&lt;/p&gt;
&lt;h3&gt;
  
  
   Loose objects
&lt;/h3&gt;

&lt;p&gt;JavaScript, although it can be considered to have object-orientation it isn't really typed &lt;em&gt;(if this is a deal breaker I'd recommend looking into TypeScript)&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;All class properties are regarded as optional and so are function params.&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;function&lt;/span&gt; &lt;span class="nf"&gt;updateUserData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userObject&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;userObject&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;//we cannot guarantee any of these properties were passed &lt;/span&gt;
  &lt;span class="c1"&gt;//as part of this object or if any param was passed at all&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Truthy and falsy
&lt;/h3&gt;

&lt;p&gt;These two are good to keep in mind when starting to write JavaScript code, it's something that still catches me out.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Truthy: Is whenever an expression is considered to return "true" which can be evaluated by 3 criterias,&lt;br&gt;
•   it's not false (duh!)&lt;br&gt;
•   the object is not nil (undefined or null)&lt;br&gt;
•   it's not an empty object, for example an empty string '' &lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy" rel="noopener noreferrer"&gt;Mozilla explain this pretty well&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Falsy: Is whenever an expression is considered to return "false" by being the inverse of the 3 above. &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy" rel="noopener noreferrer"&gt;again Mozilla explain it really well&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, what does if(0) evaluate to?&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;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sarah&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//good!&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;name&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; 
  &lt;span class="c1"&gt;//checks if name is not empty, undefined or null&lt;/span&gt;
  &lt;span class="c1"&gt;//line below can be accessed&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sarah exists!&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//bad!&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;balance&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; 
  &lt;span class="c1"&gt;//javascript considers 0 as bitwise false &lt;/span&gt;
  &lt;span class="c1"&gt;//we expect that if balance is not undefined or null this line will be executed&lt;/span&gt;
  &lt;span class="c1"&gt;//welcome to falsy!&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;This will not get printed&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Functional Programming
&lt;/h3&gt;

&lt;p&gt;If you're familiar with Java 8+ functional programming, JavaScript would be all the much easier. Here are a few things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Array.prototype&lt;/strong&gt;&lt;/em&gt;: You do not require a Stream to transform a collection into a functional type. You can chain functional programming operations to any array because you get it for free with Array.prototype. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" rel="noopener noreferrer"&gt;See Mozillas documentation these functions&lt;/a&gt;. Unlike Java there is no "terminal operation". You can manipulate that collection again and again and again, unlike Streams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;.map() .flatMap() .filter() .reduce()&lt;/strong&gt;&lt;/em&gt;: These collection operators are the same as a Java. Some include &lt;em&gt;.sort()&lt;/em&gt; is comparable to Java's &lt;em&gt;.sorted()&lt;/em&gt; and &lt;em&gt;.find()&lt;/em&gt; is comparable to Java's &lt;em&gt;.findAny()&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Method references&lt;/strong&gt;: There are no method references in JavaScript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Arrow functions&lt;/strong&gt;&lt;/em&gt;: Lambdas in Java are comparable to JavaScript's arrow function, caveat is instead of -&amp;gt;, its =&amp;gt;. JavaScript doesn't care if its a Consumer or a Supplier or a Function.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Consumer&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;printString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;printString&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;apply&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In JavaScript&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;const&lt;/span&gt; &lt;span class="nx"&gt;printString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;printString&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Files
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Casing
&lt;/h4&gt;

&lt;p&gt;The standard is that JS files are cased using kebab-case. Class names are PascalCase. Variables are camelCase. To be clear, if you have a string utils class for example, the class name should be StringUtils and the file name should be something like string-utils.js&lt;/p&gt;

&lt;h4&gt;
  
  
  File names
&lt;/h4&gt;

&lt;p&gt;File names do not have to correlate to the class name. Sometimes a files name will have its function within it prefixed and suffixed with a dot. For example a user REST controller class could be named something like user.controller.js. &lt;/p&gt;

&lt;h4&gt;
  
  
  var vs const vs let
&lt;/h4&gt;

&lt;p&gt;Variables are defined using var, const or let with ES6.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;var's scope is not limited by the code block it was defined in. Very different to Java.&lt;/li&gt;
&lt;li&gt;let's scope is limited to its code block and it is a variable&lt;/li&gt;
&lt;li&gt;const's scope is limited to its code block and it is a constant (like final modifier)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;forMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;forLetMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; world&lt;/span&gt;&lt;span class="dl"&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;forConstMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;forMessage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//hello&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;forLetMessage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//Error&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;forConstMessage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//Error&lt;/span&gt;

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  Class/Function scope
&lt;/h4&gt;

&lt;p&gt;Unlike Java, JavaScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is a procedural language, if you attempt to use a function above its definition, it is out of scope&lt;/li&gt;
&lt;li&gt;file names can be anything&lt;/li&gt;
&lt;li&gt;many "public" classes can reside in one file (do not do this however its not great practise)&lt;/li&gt;
&lt;li&gt;there are no packages, and no public, private, protected or default access modifiers&lt;/li&gt;
&lt;li&gt;for a class to be public it must be exported&lt;/li&gt;
&lt;li&gt;functions can be exported on their own
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;////////////////////////////////////////////&lt;/span&gt;
&lt;span class="c1"&gt;// Using EC5 exports&lt;/span&gt;
&lt;span class="c1"&gt;// file utils-one.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stringTrimmer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&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="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StringUtil&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;export&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;StringUtil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stringTrimmer&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;////////////////////////////////////////////&lt;/span&gt;
&lt;span class="c1"&gt;// OR using ES6 exports&lt;/span&gt;
&lt;span class="c1"&gt;// file utils-two.js&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;stringTrimmer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&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="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&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="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StringUtil&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;////////////////////////////////////////////&lt;/span&gt;
&lt;span class="c1"&gt;// Function scope&lt;/span&gt;
&lt;span class="c1"&gt;//&lt;/span&gt;

&lt;span class="nf"&gt;printString&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&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Bad, not accessible&lt;/span&gt;

&lt;span class="nf"&gt;printString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;printString&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&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Good, accessible&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Promises
&lt;/h3&gt;

&lt;p&gt;Promises are asynchronous objects that it promises to callback with a result, which is either resolved or rejected. &lt;/p&gt;

&lt;p&gt;A great analogy for Promises is making an order at a restaurant. The single thread worker is the waiter and the order is the task. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmcscyttvlvixqysnglll.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmcscyttvlvixqysnglll.gif" alt="Restaurant gif" width="800" height="345"&gt;&lt;/a&gt;&lt;br&gt;
Shout out to Jo Franchetti' &lt;a href="https://medium.com/samsung-internet-dev/promises-promises-c91d454aea11" rel="noopener noreferrer"&gt;medium post&lt;/a&gt; of that awesome GIF&lt;/p&gt;

&lt;p&gt;You can make an order with the waiter, they will then place that order and in the meantime take another orders. When your order is complete, the waiter bring it to you when they're next free. Note the waiter did not wait at the counter until the order was complete.&lt;/p&gt;

&lt;p&gt;The resolve or rejection values are returned into two functions,&lt;br&gt;
&lt;em&gt;.then()&lt;/em&gt; and &lt;em&gt;.catch()&lt;/em&gt; respectively.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;.then&lt;/em&gt;&lt;/strong&gt; is when a callback was successful, the parameters in the arrow function (lambda expression) is the return from the asynchronous call, in this case it was your completed order.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;.catch&lt;/em&gt;&lt;/strong&gt; is when the callback was rejected, an error was thrown. The param passed into the arrow function here is the error that was thrown.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Kitchen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;donuts&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;completedOrder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bon appetit&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;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sorry, we&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="nx"&gt;re&lt;/span&gt; &lt;span class="nx"&gt;all&lt;/span&gt; &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Can&lt;/span&gt; &lt;span class="nx"&gt;I&lt;/span&gt; &lt;span class="nx"&gt;offer&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;muffin&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;);
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Logging
&lt;/h3&gt;

&lt;p&gt;There are many great JavaScript logger libraries to use, to list a few of the popular ones; Winston, Morgan or log4js. Each of these have transport capabilities, logs can transport to console, a file or a cloud logger like Amazon CloudWatch or LogDNA.&lt;/p&gt;
&lt;h3&gt;
  
  
  ESLint
&lt;/h3&gt;

&lt;p&gt;Although JavaScript isn't compiled you can run static code analysis tool for identifying problematic patterns with ESLint.  Unlike a compiler, ESLint has rules that are configurable and loaded into builds or IDE.&lt;/p&gt;

&lt;p&gt;I like AirBnB's ESLinter, its fairly comprehensive and thorough. It holds me to write to a good and consistent standard. To get started use &lt;a href="https://www.npmjs.com/package/eslint-config-airbnb" rel="noopener noreferrer"&gt;npm to install&lt;/a&gt; the ESLinter or &lt;a href="https://github.com/airbnb/javascript" rel="noopener noreferrer"&gt;read the rules on their GitHub&lt;/a&gt; (packed with good, bad and very bad examples, it's pretty cool).&lt;/p&gt;
&lt;h3&gt;
  
  
  Libraries
&lt;/h3&gt;

&lt;p&gt;Finally here are a few libraries that are a must have in any JavaScript project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://momentjs.com" rel="noopener noreferrer"&gt;moment&lt;/a&gt;: A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://lodash.com/" rel="noopener noreferrer"&gt;lodash&lt;/a&gt;: Lodash (previously underscore) is a JavaScript library which provides utility functions for common programming tasks using the functional programming paradigm. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/axios" rel="noopener noreferrer"&gt;axios&lt;/a&gt;: Axios is a promise-based HTTP client that works both in the browser and in a node environment. &lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  📥📤 Node Express
&lt;/h1&gt;

&lt;p&gt;We've already discussed Node but what is Express? Express is a web application framework for Node, it is designed for building web applications and APIs. It's popularity is based on its simplicity and ease of use. &lt;em&gt;(Emphasis on the simplicity, the Spring ecosystem offers Security and Access Decision Voters that Express does not)&lt;/em&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;

&lt;p&gt;I've found the 3 layer architecture to be the cleanest way to separate the concerns following the SOLID principles.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controller&lt;/strong&gt;: this layer holds logic for API router endpoints, middleware like user management (authorisation, authentication, user session), domain access and controller (return response object, headers, status).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service&lt;/strong&gt;: the business logic should only live in this layer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Access&lt;/strong&gt;: database models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpjs0hhtth4ym29okmnu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpjs0hhtth4ym29okmnu8.png" alt="Alt Text" width="800" height="643"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Folder structure (without test)
&lt;/h3&gt;

&lt;p&gt;File name examples (for user)&lt;br&gt;
user.controller.js&lt;br&gt;
user.service.js&lt;br&gt;
user.model.js&lt;br&gt;
user.dto.js&lt;br&gt;
user.router.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;assets
└───i18n                # Translation .json files 
config                  
src
└───api                 # Express API logic
    └───controller      # Only should access Controller if authenticated and authorised
    └───middleware      # Auth, authorisation
    └───routers         # Endpoints 
└───data                
    └───dao             # DB queries
    └───entities        # Database models (entity)
└───dto                 # Data Transfer Objects
└───jobs                # Jobs like CRON
└───loaders             # Startup processes from app.js
└───services            # Business logic only lives here
└───subscribers         # Event handlers for async task
└───interfaces          # **Type declaration for DTO and Models files for Typescript
 │   app.js           # App entry point
 |   package.json       # npm tasks and dependencies
 |   .env           # Env vars and secrets

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Middleware
&lt;/h3&gt;

&lt;p&gt;The middleware intercepts an API routing logic with some function(s). Middleware is where you would typically handle authentication, authorisation, parent child relationship and controller.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4h0r068ynz89gli0vgxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4h0r068ynz89gli0vgxu.png" alt="Request middleware response flow author Sarah Ksiyer" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Middleware ordering is important, the logic that is chained can break at any point. I would advise authentication comes first for obvious reasons.&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;//for all routes with /api will go through auth()&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;auth&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="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
   &lt;span class="c1"&gt;//req is the API request object&lt;/span&gt;
   &lt;span class="c1"&gt;//res is the API response object, could be used to throw unauthorised&lt;/span&gt;
  &lt;span class="c1"&gt;// some logic..&lt;/span&gt;
  &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;//next is used when things are good move on to the next middleware&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For authentication I'd recommend looking into &lt;a href="https://jwt.io/" rel="noopener noreferrer"&gt;JWT&lt;/a&gt; (JSON Web Tokens). For password hash and salting I would highly recommend &lt;a href="https://www.npmjs.com/package/bcrypt#usage" rel="noopener noreferrer"&gt;bcrypt&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
   Secrets and configs
&lt;/h3&gt;

&lt;p&gt;Secrets are stored in the root .env file. This is accessed via process&lt;br&gt;
E.g: .env file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=8080
DB_DATABASE=my_db
DB_USER=sa
DB_PASSWORD=P4s5w0r1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Environment loader:&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;////////////////////////&lt;/span&gt;
&lt;span class="c1"&gt;// Environment Loader&lt;/span&gt;
&lt;span class="c1"&gt;// env.loader.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dotenv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&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;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;dotenv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;config&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="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_DATABASE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_USER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_PASSWORD&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;h3&gt;
  
  
  ORM - Object Relational Mapping
&lt;/h3&gt;

&lt;p&gt;The two most popular ORMs are &lt;a href="https://sequelize.org/v5/" rel="noopener noreferrer"&gt;Sequelize&lt;/a&gt; and &lt;a href="https://typeorm.io/#/" rel="noopener noreferrer"&gt;TypeORM&lt;/a&gt;. Sequelize is a JavaScript library that can be used by TypeScript as well. TypeORM is purely a TypeScript that heavily uses annotations on entities (models). TypeORM is closer to Hibernate with JPA style approach.&lt;/p&gt;

&lt;p&gt;Both ORM's support a wide variety of database dialects from RDBMS to NoSQL.&lt;/p&gt;

&lt;p&gt;However you may be pleased to hear that unlike Hibernate, these ORM also handle migrations. Thats right, you no longer require another framework like FlywayDB or Liquibase for migrations. It's nice to have this all in one place.&lt;/p&gt;

&lt;p&gt;Both have great documentation and support, which you chose will depend on your coding style. Which leads me to my next and final topic...&lt;/p&gt;

&lt;h1&gt;
  
  
  ⌨️ TypeScript vs JavaScript
&lt;/h1&gt;

&lt;p&gt;So far we've discussed JavaScript, Node, Express, Architecture and ORMs... you may be thinking what else is there? &lt;/p&gt;

&lt;p&gt;To summarise JavaScript is a great scripting language, especially with ECMAScript latest versions. However, JavaScript is a procedural language, it isn't compiled so errors are usually found at runtime, its has a loose un-typed models that make hard to ensure functions/classes are used as intended and its missing access modifiers that help use of basic design patterns like the singleton pattern.&lt;/p&gt;

&lt;p&gt;This is where TypeScript comes to the rescue. TS which was developed by Microsoft is a scripting language, that addresses these very problems. Since JavaScript isn't a compiled language, TypeScript is transformed into JavaScript through transpilation (simplicity its referred to as compilation so I will too). &lt;/p&gt;

&lt;p&gt;So what does TypeScript have that JavaScript does not?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is typed&lt;/li&gt;
&lt;li&gt;It isn't procedural &lt;/li&gt;
&lt;li&gt;It has a "compiler" that tells you before runtime if something is wrong&lt;/li&gt;
&lt;li&gt;Classes &amp;amp; Interfaces can have optional/required properties to keep benefits of a flexible model&lt;/li&gt;
&lt;li&gt;Function parameters can be optional/required also&lt;/li&gt;
&lt;li&gt;It has access modifiers, annotations, abstraction and interfaces&lt;/li&gt;
&lt;li&gt;It supports dependency injections&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With that said you can see that TS is heavily influenced by C# so naturally it feels so familiar... and thats the problem.&lt;/p&gt;

&lt;p&gt;So far I've tried to remain impartial however heres my 2 pence. In my opinion to really benefit from what TypeScript offers you need to understand what JavaScript offers first. Starting with TS from the jump will lead you writing solutions in a completely OOP way. Which misses the point of using a lighter server-side scripting runtime like Node. &lt;/p&gt;

&lt;p&gt;TypeScript brings a lot to the table &lt;strong&gt;on top&lt;/strong&gt; of what JavaScript already does. &lt;/p&gt;

</description>
      <category>node</category>
      <category>java</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
