<?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: Ubani Friday</title>
    <description>The latest articles on DEV Community by Ubani Friday (@callmefarad).</description>
    <link>https://dev.to/callmefarad</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%2F559028%2Ff8e15fdb-281c-444d-90f9-35be3ffedde4.JPG</url>
      <title>DEV Community: Ubani Friday</title>
      <link>https://dev.to/callmefarad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/callmefarad"/>
    <language>en</language>
    <item>
      <title>Understanding Dependency Versioning and Updating</title>
      <dc:creator>Ubani Friday</dc:creator>
      <pubDate>Sun, 13 Feb 2022 16:27:22 +0000</pubDate>
      <link>https://dev.to/callmefarad/understanding-dependency-versioning-and-updating-4g53</link>
      <guid>https://dev.to/callmefarad/understanding-dependency-versioning-and-updating-4g53</guid>
      <description>&lt;p&gt;This tutorial will focus on everything you need to know within your package.json as regards versioning and how your dependency update works but before we get started, let's take a road map to achieving this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What Is Dependency Version?&lt;/li&gt;
&lt;li&gt;Major, Minor and Patch.&lt;/li&gt;
&lt;li&gt;Updating Dependency.&lt;/li&gt;
&lt;li&gt;The Charet (^) Character &amp;amp; how It works.&lt;/li&gt;
&lt;li&gt;The Tildle (~) Character &amp;amp; How It Works.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is Dependency Versioning?
&lt;/h2&gt;

&lt;p&gt;Dependency version represents the three(3) digits separated with a period(.) that is mapped to the actual dependency name. See sample file below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "night",
  "version": "1.0.0",
  "description": "a simple REST API with express",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "Dev": "nodemon server.js"
  },
  "keywords": [
    "nodejs",
    "express",
    "nodemon"
  ],
  "author": "Ubani Friday",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.2"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

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

&lt;/div&gt;



&lt;p&gt;Look closely at the sample above, you will see two dependencies express and nodemon installed. We would focus on the express library.&lt;br&gt;
&lt;code&gt;"express": ^4.17.2&lt;/code&gt;&lt;br&gt;
express signifies the dependency name while ^4.17.2 signifies the version. The three digits signifies Major, Minor and Patch. Let me take you on a ride on what these three digit really means.&lt;/p&gt;
&lt;h2&gt;
  
  
  MAJOR
&lt;/h2&gt;

&lt;p&gt;This is the first digit from the version number representing a change in the API of the dependency. This means that if there is a change in the API of the dependency, the value of the major version increases.&lt;/p&gt;
&lt;h2&gt;
  
  
  MINOR
&lt;/h2&gt;

&lt;p&gt;This is the second digit from the version number representing a change in features/functionality of the dependency. This implies that if there is a change in features/functionality of the dependency, the value of the minor version increases.&lt;/p&gt;
&lt;h2&gt;
  
  
  PATCH
&lt;/h2&gt;

&lt;p&gt;Patch is the last digit of the version number representing any change in bug fixing. This implies that once a bug is detected in a dependency and was fixed, there will be an increase in the value of the patch version.&lt;/p&gt;
&lt;h2&gt;
  
  
  Updating Dependency
&lt;/h2&gt;

&lt;p&gt;Updating a dependency is the change that occurs in the value of the dependency version and this is triggered by two factors which are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Charet(^) Character&lt;/li&gt;
&lt;li&gt;Tildle(~) Character&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Charet (^) Character
&lt;/h2&gt;

&lt;p&gt;The charet (^) character is used to prefix dependency version in order to bypass code breaking when there is a change in the version of that dependency. It also allows node package manager(npm) to install updates of both MINOR and PATCH versions.&lt;br&gt;
Let's say we install express version of 4.16.0 using &lt;code&gt;npm i express@4.16.0&lt;/code&gt; we would have our dependency looking like the sample below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "night",
  "version": "1.0.0",
  "description": "a simple REST API with express",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "Dev": "nodemon server.js"
  },
  "keywords": [
    "nodejs",
    "express",
    "nodemon"
  ],
  "author": "Ubani Friday",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the latest version of express was considered to be used, we then run this command to show the old and latest versions &lt;code&gt;npm outdated&lt;/code&gt; see sample image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffv73r3rna8jlqxutfqku.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffv73r3rna8jlqxutfqku.PNG" alt="showing charet changes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will notice that the wanted version and updated versions is the same signifying that there was a change in the MINOR and PATCH versions. We can now update the dependency to the latest version by entering the command &lt;code&gt;npm update&lt;/code&gt;. At complete installation, the version of express will be changed/updated to the latest version as show below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "night",
  "version": "1.0.0",
  "description": "a simple REST API with express",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "Dev": "nodemon server.js"
  },
  "keywords": [
    "nodejs",
    "express",
    "nodemon"
  ],
  "author": "Ubani Friday",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.2"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tildle (~) Character
&lt;/h2&gt;

&lt;p&gt;The tildle (~) character is used to prefix dependency version in order to bypass code breaking when there is a change in the version of that dependency. It only accept a change in the PATCH version of the dependency.&lt;br&gt;
Let's understand this better by changing the charet (^) character of the express version installed earlier to tildle (~) character. see sample below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "night",
  "version": "1.0.0",
  "description": "a simple REST API with express",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "Dev": "nodemon server.js"
  },
  "keywords": [
    "nodejs",
    "express",
    "nodemon"
  ],
  "author": "Ubani Friday",
  "license": "ISC",
  "dependencies": {
    "express": "~4.16.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

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

&lt;/div&gt;



&lt;p&gt;If we try to check the latest version of the dependency on the terminal of our VSCode by entering the command &lt;code&gt;npm outdated&lt;/code&gt; &lt;br&gt;
see sample image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgu31b9qo6966ul6py0ul.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgu31b9qo6966ul6py0ul.PNG" alt="showing tildle changes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we will notice that we the wanted version is different from the latest version unlike the result shown when we ran the outdated command earlier on a charet(^) version of express. Therefore, we can update to the wanted version by entering the command &lt;code&gt;npm i express@4.16.4&lt;/code&gt;&lt;br&gt;
see final sample below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "night",
  "version": "1.0.0",
  "description": "a simple REST API with express",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "Dev": "nodemon server.js"
  },
  "keywords": [
    "nodejs",
    "express",
    "nodemon"
  ],
  "author": "Ubani Friday",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.4"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

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

&lt;/div&gt;



&lt;p&gt;After which you can now change the charet character &lt;code&gt;"express": "^4.16.4"&lt;/code&gt; to tildle character &lt;code&gt;"express": "~4.16.4"&lt;/code&gt;&lt;br&gt;
If you find this tutorial useful, do well to click like and follow me to get my future articles.&lt;br&gt;
Socialize with me on:&lt;br&gt;
&lt;a href="https://twitter.com/callmefarad" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/callmefarad/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Am also open to being your guest on virtual training on this stack (MERN)&lt;br&gt;
Thanks for your time.&lt;/p&gt;

</description>
      <category>express</category>
      <category>tildle</category>
      <category>chare</category>
      <category>dependen</category>
    </item>
    <item>
      <title>Protecting your files on GitHub</title>
      <dc:creator>Ubani Friday</dc:creator>
      <pubDate>Sun, 12 Dec 2021 08:39:32 +0000</pubDate>
      <link>https://dev.to/callmefarad/protecting-your-files-on-github-42p3</link>
      <guid>https://dev.to/callmefarad/protecting-your-files-on-github-42p3</guid>
      <description>&lt;p&gt;I made a tutorial on how to create a &lt;a href="https://dev.to/callmefarad/simple-nodejs-server-1ee6"&gt;&lt;strong&gt;Simple Node.js Server&lt;/strong&gt;&lt;/a&gt; which will serve as a basis for this tutorial as this tutorial will focus mainly on how to protect our files on GitHub.&lt;/p&gt;

&lt;p&gt;Let's get started. &lt;br&gt;
Adding protection to our files makes it safe from hackers on the web whose intentions are in a negative direction. To get rid of such people, there is need to protect our files on the local repository before pushing them to GitHub using Git.&lt;/p&gt;

&lt;p&gt;To do this, we would need to add a file to the previous application whose GitHub link is provided above.&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding .gitignore file
&lt;/h2&gt;

&lt;p&gt;Create a file and name it ".gitignore" without the quote.&lt;br&gt;
Open the file.&lt;br&gt;
Enter the name of the file you want to save.&lt;/p&gt;

&lt;p&gt;See sample code and image below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3n7ztWmT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zcmhk8du1eqbjo4jm8kh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3n7ztWmT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zcmhk8du1eqbjo4jm8kh.PNG" alt="Image description" width="880" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.gitignore is a directory that hides whatever file that is placed in it. Here we will hide the node_modules file from the viewers so as to reduce the size of our app when pushed to GitHub. By doing so, the file(node_modules) will no longer be visible to viewers who try to access the public repository on GitHub.&lt;/p&gt;

&lt;p&gt;When all is done you can now push your local repository to GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fq_q7jnH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwod9owjsibj65gx2lle.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fq_q7jnH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwod9owjsibj65gx2lle.PNG" alt="Image description" width="880" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the sample image above you will notice that the node_modules directory on your local repository is no longer on remote repository.&lt;/p&gt;

&lt;p&gt;Get the sample code on &lt;a href="https://dev.to/callmefarad/simple-nodejs-server-1ee6"&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I look forward to hearing from you by leaving a message on the comment tag.&lt;br&gt;
Drop a like if this tutorial was helpful and follow me to get all my tutorials.&lt;/p&gt;

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

</description>
      <category>node</category>
      <category>github</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Simple NodeJS Server</title>
      <dc:creator>Ubani Friday</dc:creator>
      <pubDate>Fri, 10 Dec 2021 16:21:58 +0000</pubDate>
      <link>https://dev.to/callmefarad/simple-nodejs-server-1ee6</link>
      <guid>https://dev.to/callmefarad/simple-nodejs-server-1ee6</guid>
      <description>&lt;p&gt;In this tutorial, you will learn how to create a simple server with node.js. Bellow is a brief definition of a Server and NodeJS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server&lt;/strong&gt; is a computer program or device that provides a service to another computer program and its user, also known as the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NodeJS&lt;/strong&gt; is simply an open source, cross-platform runtime environment that runs on a V8 engine for developing server-side, networking applications thereby allowing JavaScript to run outside the web.&lt;/p&gt;

&lt;p&gt;The following technology will be used in the cause of this tutorial.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JavaScript (An object oriented programming language)&lt;/li&gt;
&lt;li&gt;Node.js (A runtime environment)&lt;/li&gt;
&lt;li&gt;VSCode (An Integrated Development Environment-IDE)&lt;/li&gt;
&lt;li&gt;POSTMAN (A application to run our request)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's get started. &lt;/p&gt;

&lt;h2&gt;
  
  
  Initiating Node.js
&lt;/h2&gt;

&lt;p&gt;To create a server on node.js, you must first launch the IDE of your choice (VSCode in my case), then you will need to run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init --y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;npm&lt;/strong&gt; is a short for Node Package Manager which helps to install node packages. Some packages will be installed as soon as you hit the enter key after entering the above command. see sample below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kFHSa-4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyfuireynbm13hgl3l6s.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kFHSa-4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyfuireynbm13hgl3l6s.PNG" alt="Image description" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have successfully set up our node environment, the next thing is to create a server on this environment. &lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a server
&lt;/h2&gt;

&lt;p&gt;Create a new file and name it server.js at the left pane(Explorer) of VSCode. If all is done as directed, you will have a replica of the below sample image. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6in9vQrJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bxp1fv81auw5qustb5r.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6in9vQrJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bxp1fv81auw5qustb5r.PNG" alt="Image description" width="321" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now that we have the server.js file created it does nothing because it is currently an empty file. Let dive in to the code base bellow.&lt;/p&gt;

&lt;p&gt;First we install a package called "express" with the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i express.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OOPS!!! just remembered i haven't gave a brief on what express is. &lt;strong&gt;Express&lt;/strong&gt; is a back end web application framework for Node.js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const port = 2021;

const app = express();
app.get('/', (req, res) =&amp;gt; {
    res.send('A Simple Node.js Server is Up and Running.......')
})
app.listen(port, ()=&amp;gt;{
    console.log(`Server is listening on port ${port}`)
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First we imported the express module. After importing express, we set a port at which our server will run on, next created an instance of the express module imported. The essence of creating that instance is to help us utilize everything express has to offer us(say its functions).&lt;/p&gt;

&lt;p&gt;We use the instance app created to fire our first request(GET METHOD) so as to look for a route that matches "/", after which a response follows up rendering the required content to our client/browser using the &lt;code&gt;res.send()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Now that we have all our lines of code, we are left with running this application so as to completely confirm that our server is really up and running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the server
&lt;/h2&gt;

&lt;p&gt;To run our server, we need to first lunch a terminal by clicking on the terminal option at the menu or use a shortcut (ctrl + j) then  enter the command below inside the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xsk8nwwQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yx8jl4xc3ow54v9u5ow7.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xsk8nwwQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yx8jl4xc3ow54v9u5ow7.PNG" alt="Image description" width="880" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once this is done, we would see a message on the terminal showing that our server is up running on port 2021 but the content of the response isn't displayed. This is because we only ran our server but haven't sent a request so if we are to see the response, we need to use either a Browser, POSTMAN or Thunder Client(an extension provided by VSCode) to send a request that is based on the endpoint created which is "/" in our case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sending a request
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lunch POSTMAN&lt;/li&gt;
&lt;li&gt;Enter this URL in the URL address bar: &lt;code&gt;http://localhost:2021/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Change the request method to GET&lt;/li&gt;
&lt;li&gt;Click on the SEND button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This sample image shows that all is done and dusted as our server is running and our first response was gotten.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aQTIyQp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1emop3pwubieju3y7e1l.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aQTIyQp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1emop3pwubieju3y7e1l.PNG" alt="Image description" width="880" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can get the full code to this tutorial &lt;a href="https://github.com/callmefarad/Simple-NodeJS-Server"&gt; here &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Trust you've learnt how to create a simple server with node.js.&lt;br&gt;
Give me a like or follow to get all my tutorials.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Simple Query Search in Node Express API</title>
      <dc:creator>Ubani Friday</dc:creator>
      <pubDate>Tue, 16 Nov 2021 08:42:07 +0000</pubDate>
      <link>https://dev.to/callmefarad/simple-query-search-in-node-express-api-4c0e</link>
      <guid>https://dev.to/callmefarad/simple-query-search-in-node-express-api-4c0e</guid>
      <description>&lt;p&gt;REST API has become one of the most use protocol for building and integrating application software. It is most refer to as RESTful API which stands for REpresentational State Transfer Application Programming Interface.&lt;/p&gt;

&lt;p&gt;My interest is to show how we can create a search query in a REST API. Let me take you on a ride &lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Node
&lt;/h3&gt;

&lt;p&gt;Launch your preferred IDE, am using &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;VSCode&lt;/a&gt;  in my case and enter the code to initiate a node package.&lt;br&gt;
&lt;code&gt;npm init --y&lt;/code&gt;&lt;br&gt;
After a successful installation of node package, next we have to install the necessary dependencies. The code below installs our needed dependencies.&lt;br&gt;
&lt;code&gt;npm i express&lt;/code&gt;&lt;br&gt;
&lt;code&gt;npm i nodemon --save-dev&lt;/code&gt;&lt;br&gt;
You might want to know why the nodemon has a different installation command, YES that's because we only need it just for development purpose but if our application is to be hosted it won't be needed as the keyword &lt;code&gt;node&lt;/code&gt; will be used as a command to run our application.&lt;/p&gt;

&lt;p&gt;We have successfully install node and the necessary dependencies that is need, lets dive to our main focus.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Server
&lt;/h3&gt;

&lt;p&gt;The first thing to do is to create a file that our codebase would will live. Get to the terminal and create a file named "&lt;b&gt;server.js&lt;/b&gt;".&lt;br&gt;
&lt;code&gt;touch server.js&lt;/code&gt;&lt;br&gt;
The file will be created at the explorer nav of your VSCode, all you need is to double click on it to open.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnhebl8roj24l4bav5n7.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnhebl8roj24l4bav5n7.PNG" alt="server"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We required our express library in our file so as to make use of its handle helper functions. Next we created a port on which our server will run on. Now that we have access to the express library an instantiation of it with a variable name "app" was declared to make usage appealing but note the variable name is self define which means you can make a declaration of your choice of name. &lt;br&gt;
An array of dummy/static data was created for the students containing their information then we created a default routed that throws a welcome message as respond to the user.&lt;/p&gt;

&lt;p&gt;Finally, we used the instance of express declared as "app" to point to the &lt;code&gt;listen()&lt;/code&gt; method to make sure that server is successfully up and running.&lt;/p&gt;

&lt;p&gt;Let's run our server to make sure we are on the right track.&lt;br&gt;
&lt;code&gt;npm start&lt;/code&gt;&lt;br&gt;
The above code was made possible because we edited the scripts in package.json file as follows: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


"scripts": {
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1",
    "start": "nodemon server.js"
  },



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

&lt;/div&gt;

&lt;p&gt;Next we have to request to the server using POSTMAN. Enter &lt;a href="http://localhost:2021" rel="noopener noreferrer"&gt;http://localhost:2021&lt;/a&gt; in the url provided and make sure the method is set to &lt;b&gt;GET&lt;/b&gt; then hit enter or click on the &lt;b&gt;send&lt;/b&gt; button. Result is shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6p2cd94hk4mdpshchcix.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6p2cd94hk4mdpshchcix.PNG" alt="POSTMAN responds"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Query Search
&lt;/h3&gt;

&lt;p&gt;Now that we have our server and responds running, it is time to write our route for searching specific information.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


app.get("/student", async (req, res) =&amp;gt; {
  try{
    const userQuery = await req.query;
        const filteredStudent = await studentInformations.filter((info)=&amp;gt;{
            let isValid = true;
            for(key in userQuery) {
                isValid = isValid &amp;amp;&amp;amp; info[key] === userQuery[key];
            }
            return isValid;
        });
        res.json({data: filteredStudent})
  }catch(err){
    res.send(err.message)
  }
});



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

&lt;/div&gt;

&lt;p&gt;Brief explanation of sample code: First we get the user request passed as a parameter on the url then filter the database objects based on key after which we loop through the database objects and check if any of the object key from the loop matches what is passed by the user in the url and finally every matched object is now filtered and returned as a responds to the user.&lt;/p&gt;

&lt;h4&gt;
  
  
  Result
&lt;/h4&gt;

&lt;p&gt;We want to show all student that took a "Frontend" course. This request would be sent &lt;code&gt;&lt;a href="http://localhost:2021/student?course=Frontend" rel="noopener noreferrer"&gt;http://localhost:2021/student?course=Frontend&lt;/a&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrthu2pnm61wdcx42h7f.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrthu2pnm61wdcx42h7f.PNG" alt="query search request"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all.&lt;br&gt;
Hope this helps you hit the like icon and comment for clarity if there is any.&lt;br&gt;
You can get the complete source code from my GitHub repo &lt;a href="https://www.github.com/callmefarad/Simple-Search-Query-In-Node-Rest-API" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the follow button to always get my posts.&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>query</category>
      <category>api</category>
    </item>
    <item>
      <title>Difference between var, let and const</title>
      <dc:creator>Ubani Friday</dc:creator>
      <pubDate>Tue, 09 Nov 2021 17:16:48 +0000</pubDate>
      <link>https://dev.to/callmefarad/difference-between-var-let-and-const-4kc</link>
      <guid>https://dev.to/callmefarad/difference-between-var-let-and-const-4kc</guid>
      <description>&lt;p&gt;The word var, let and const are keywords for declaring JavaScript variables. Var is an earliest way for declaring variables and still in use by many while let and const is a modern way of declaring variables but there is a difference in using any of them. I will use JavaScript block scope to explain them.&lt;/p&gt;

&lt;p&gt;VAR: When a variable is declared using the keyword 'var', it does not follow JavaScript block scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5zk2e615h90hgp4ibhg.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5zk2e615h90hgp4ibhg.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the code base above, you will observe that the program ran because the keyword "var" does not obey JavaScript block scope. The program was able to compile the global variables which are age = 45, name = 'Malush' and address = '23' despite that the variable 'address' was in a local scope.&lt;/p&gt;

&lt;p&gt;LET and CONST: Unlike the 'var' keyword, the 'let' and 'const' obeys JavaScript block scope therefore making the program to fail and throw a ReferenceError of "address is not defined".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66a14pn8m3v5rd96kui4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66a14pn8m3v5rd96kui4.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This error just as it were above shows that the variable address declared with the keyword 'let' could not be reached because the variable address was declared within a local scope.&lt;/p&gt;

&lt;p&gt;In summary, variable declared with "var" are exposed globally irrespective of its local block, "let" is used to declare a variable which can change at anytime and "const" is used to declare a variable which you don't want to change in the course of that program.&lt;/p&gt;

&lt;p&gt;If this was educating please drop a comment and follow me on twitter: &lt;a href="https://twitter.com/callmefarad" rel="noopener noreferrer"&gt;https://twitter.com/callmefarad&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>variables</category>
      <category>let</category>
      <category>const</category>
    </item>
  </channel>
</rss>
