<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kaveen Laksitha on Medium]]></title>
        <description><![CDATA[Stories by Kaveen Laksitha on Medium]]></description>
        <link>https://medium.com/@KaveenLaksitha?source=rss-239052e48928------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AUC3mnLNLthsH6lLQmlNaw.jpeg</url>
            <title>Stories by Kaveen Laksitha on Medium</title>
            <link>https://medium.com/@KaveenLaksitha?source=rss-239052e48928------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:08:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@KaveenLaksitha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[package.json and package-lock.json]]></title>
            <link>https://medium.com/@KaveenLaksitha/package-json-and-package-lock-json-b39420edb3ab?source=rss-239052e48928------2</link>
            <guid isPermaLink="false">https://medium.com/p/b39420edb3ab</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Kaveen Laksitha]]></dc:creator>
            <pubDate>Sun, 15 May 2022 10:41:40 GMT</pubDate>
            <atom:updated>2022-05-15T16:43:04.990Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*xuAYFgf3xxKyjO5M6-Cfmg.jpeg" /></figure><h4>difference between the package.json and package-lock.json</h4><h4>Introduction</h4><p>Package.json and package-lock.json are two files that are used to manage your packages in node and npm. In this article I’ll explain the difference between package.json file and package-lock.json file and also Semantic Versioning using npm. Let’s jump into the article.</p><h4>Package.json and package-lock.json</h4><p>To explain this, I’ll create a folder called “<strong>test</strong>” and I’m gonna initialize a new project here using “<strong>npm init -y”.</strong> This will create an empty “<strong>package.json</strong>” file and it looks like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*snSS3LnUWSLArWd2loJN9Q.png" /><figcaption>figure 01: package.json</figcaption></figure><p>For this purpose, Let’s imagine we want to create a API and we need to install some packages in order to function it correctly. For this scenario we’ll imagine I’m creating an API using express and node. So first we have to install “<strong>express</strong>” using npm.</p><pre>npm install express</pre><p>At the moment you run above command, npm will update the package. First it will download the express package, put it locally and then update the package.json file. After installing this package, you will notice is newly created one directory called “<strong>node_modules</strong>” and one file called “<strong>package.json</strong>”. After installing express, my package.json file will look like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*YtkH4gY5YrmdwznoEaRMpg.png" /><figcaption>figure 02: package.json</figcaption></figure><p>It added a new dependency and the version here is “^<strong>4.18.1</strong>”. This is called the “<strong>Semantic Versioning</strong>”. All versions have 3 digits.</p><ul><li>the first digit is the major version</li><li>the second digit is the minor version</li><li>the third digit is the patch version</li></ul><p>And also you may notice there is a symbol start of the version. That character symbol as caret(^). It is used to define set of some rules by npm. Also there is another symbol that mostly used. It is tilde(~) symbol. There is a list of symbols but I am not going to describe those in detail here. You can get to know more about them referring this <a href="https://nodejs.dev/learn/semantic-versioning-using-npm"><strong>link</strong></a>. So, what is the meaning of using caret symbol?. It basically saying that hey, feel free to upgrade the patch and minor, but keep this package at major version four. So that major version doesn’t change. If we use tilde(~) instead of caret(^), it means that npm can upgrade patch, but don’t update minor. You can go up to 4.18.<strong>9 but keep the 4.17</strong>.</p><p>You may notice that our package.json is <strong>not really fixed, it keeps changing. </strong>So, if I push this into remote repository and imagine new minor version of express is released. After that If someone cloned my project and he/she do an npm install. What happens when he/she do that? that person is not going to get <strong>4.17 </strong>version that I installed. He/she going to get <strong>4.18 </strong>because there is a newer version of express minor is released.</p><p>So people who created Node, they invented this idea of “<strong>package-lock</strong>”. When you install or update your packages, a package-lock.json file will be created. It is literally setting the actual version that are used on specific project. Package-lock.json have all the dependencies and their identical versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*GQGTJ6KdI_zUQQAlobvzUQ.png" /><figcaption>figure 03: package-lock.json</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Zn-29ReeZeufTgj13SGWA.png" /><figcaption>figure 04: package-lock.json</figcaption></figure><p>Let’s imagine that you want to go back to express version 4.16 and you don’t want to go up. So what you have to do is go to packge.json file and change the version back to 4.16.3(patch can be decided by your choice) and insert tilde(~) symbol start of the version number.. Then the package.json will look like below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*xg288Kepg1Rx80wj3GhQcA.png" /><figcaption>figure 05: package.json</figcaption></figure><p>Now your package-lock.json file is out of date because you have changed the dependency version. To update it all you have to do is do npm install. Actually npm install what does is it overwrite your package-lock.json , whatever it needs to override. Once the npm install done, we can see a output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*I61GqZzQj2jgG_aJ5eyNIQ.png" /><figcaption>figure 06: terminal output</figcaption></figure><p>It says removed 9 packages. Those are the packages that are related to the previous express version. Let’s check the package-lock.json file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*iK_i_peGT8DpoDjxi63Pcw.png" /><figcaption>figure 07: package-lock.json</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*gT99NdSsWONecrS_VpPoJA.png" /><figcaption>figure 08: package-lock.json</figcaption></figure><p>In the dependency section it says 4.16.1 but actual version of express that installed is <strong>4.16.4. </strong>So, it means the latest patch for 4.16 is actually 4.</p><p>Now you know there is a risk that when we use “npm install”, it overwrite the package-lock.json. You don’t want to do it. You have to respect what the developer was actually tested on. To do that you use an another command called <strong>“npm ci”</strong>. This command only works when you actually have a package-lock.json file. It acts like an install, but respecting the package-lock.</p><p>So, that’s all for this article and hope you find this article helpful. If there is an any error or mistake, comment below then I can fix it. Thanks and see you in the next article!🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b39420edb3ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a simple Rest API using Koa.JS and Node.JS]]></title>
            <link>https://medium.com/@KaveenLaksitha/build-a-simple-rest-api-using-koa-js-and-node-js-7dd1ab671e2f?source=rss-239052e48928------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dd1ab671e2f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[koa]]></category>
            <category><![CDATA[koajs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js]]></category>
            <dc:creator><![CDATA[Kaveen Laksitha]]></dc:creator>
            <pubDate>Sun, 15 May 2022 10:40:51 GMT</pubDate>
            <atom:updated>2022-05-15T10:40:51.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*2RZBQ9JHqYFkBxKIRJ5yYA.jpeg" /></figure><h4>Introduction to Koa.js</h4><h4><strong>Introduction</strong></h4><p>If you are a fan of dealing with APIs, you probably used Express to implement an API with Node. But you know there is also a framework called “Koa”?. It is also designed by the team behind Express. But Koa’s aims to be a very lightweight, more expressive and more robust foundation for web applications and APIs. In this article I will show you how to create a very simple REST API using Koa and Node. (If you want to read more about APIs and how it works, you can refer my <a href="https://medium.com/ms-club-of-sliit/what-is-an-api-and-how-does-it-work-4cef84e91fd9"><strong>previous</strong></a> article😉)</p><h4>Prerequisites</h4><p><strong>node v7.6.0</strong> or higher</p><p>If you don’t have installed Node in your pc, you can refer this <a href="https://nodejs.org/en/download/"><strong>link</strong></a> and install the latest LTS version.</p><h4>Project initialization</h4><p>Before we start the implementation, Let’s create a new folder called “koa-api”(you can use whatever name you want). You can use below command or your preferred method to create a new folder.</p><pre><strong>mkdir koa-api</strong></pre><p>Then I’ll navigate to newly created directory using below command.</p><pre><strong>cd koa-api</strong></pre><p>So far we have created new directory and now we are inside of it. In the beginning I mentioned Koa is a Node framework. So we can’t implement a Koa project without Node. In order to do that, we have to initialize our project with Node. To do that, we are using NPM(<strong>N</strong>ode <strong>P</strong>ackage <strong>M</strong>anager). If you don’t know what is NPM, it is a package manager for JavaScript programming. It is the default package manager for the JavaScript runtime environment Node.js and it is used to publish, discover, install, and develop node programs.</p><p>Let’s start with initializing our project directory using NPM. When we initialing the project, you can use two commands.</p><p>First one is,</p><pre><strong>npm init</strong></pre><p>When you use this command to initialize your project, it will ask for details such as project name, author name, bla bla bla. You have to provide those details and hit enter one after another.</p><p>The second command is,</p><pre><strong>npm init</strong> <strong>-y</strong></pre><p>I mostly use this command because you only have to type this command and hit enter. And boom, you’re good to go. It don’t ask any project details from you because it saves default project settings. But you can change those details later if you want.</p><p>You can use any command that I mentioned above to initialize the project and it’s up to you. After initializing the project, you will notice there is a new file called “<strong>package.json</strong>”. This file is the one that contains all the information about our newly created project.(If you already know these things, please ignore and scroll down little bit🥱).</p><h4>Installing required packages</h4><p>After we initializing our project, we have to install some packages in order to work with Koa. Using below commands, you can install the packages that required to build a simple REST API.</p><pre>npm install koa</pre><p>You already know why we want to install Koa. After you installing those packages, you will notice those packages are added to the package.json file under dependencies section.</p><h4>Implementation</h4><p>Now let’s start the coding part. Inside your project directory, create a file called “server.js”(not a rule, but it is what it is😂).</p><p>After that we have to add a script to package.json file in order to run our API. Open the package.json file and under the section called “scripts”, write below code snippet.</p><pre>&quot;start&quot;: &quot;node server.js&quot;,</pre><p>What this basically does is once we implemented our API, we have to start it. To do that we have to add above <strong>start </strong>snippet to package.json file.</p><p>Then inside the <strong>server.js</strong> file we have to import Koa and create our simple API. You can refer below code section.</p><pre>const Koa = require(&#39;koa&#39;);<br>const app = new Koa();</pre><pre>app.use(async ctx =&gt; {<br>  ctx.body = &#39;Hello from Koa!&#39;;<br>});</pre><pre>const PORT = 3000;<br>app.listen(PORT, () =&gt; {console.log(“Server running on port : “,PORT)});</pre><p>What we have done is first we stored Koa in a variable called “Koa”. Then we initialized the koa server and save it to the “app” variable. So we can use “app” variable to do anything used to do with koa. After that created simple route that will trigger when call out API. Finally, we tell our API to use port number 3000 and listen on that port. After that you need to type the command,</p><pre>npm start</pre><p>to start the server. Then simply go to “<a href="http://localhost:3000/">http://localhost:3000/</a>” and see the magic. And that’s it! We have created our very simple REST API.</p><p>Hope this article helped you to get a basic idea about Koa.js and create a very simple REST API using it.🙌🙌🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dd1ab671e2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[8 must know JavaScript array methods.]]></title>
            <link>https://medium.com/ms-club-of-sliit/8-must-know-javascript-array-methods-cbed2574ca5d?source=rss-239052e48928------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbed2574ca5d</guid>
            <category><![CDATA[array-methods]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Kaveen Laksitha]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 15:50:33 GMT</pubDate>
            <atom:updated>2022-02-26T15:50:33.646Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="article flyer" src="https://cdn-images-1.medium.com/max/880/1*KW564X7I0iK1gJ9s5DHfgw.png" /></figure><p>8 must know JavaScript array methods.</p><h4>Introduction</h4><p>Nowadays, many developers love to use JavaScript to develop their solutions. In this article, I’ll discuss about 8 array methods/functions that I love to use and think that you should be aware of. So… let’s get started😎.</p><h4>01. map( )</h4><p>This is one of the useful array methods in my knowledge. What it does is, this method iterates all through the array and creates a new array of values from the original array. If it’s confusing to understand, imagine that there is an array called <em>“cars”</em>. It has a key, value pair of brand and model. Using the code below, you can understand what I am saying.</p><pre>const cars = [</pre><pre>{ brand: &quot;Toyota&quot;, model: &quot;axio&quot; },</pre><pre>{ brand: &quot;Nissan&quot;, model: &quot;GTR R35&quot; },</pre><pre>];</pre><pre>const carBrands = cars.map((car) =&gt; {</pre><pre><em>return</em> car.brand;</pre><pre>});</pre><pre>console.log(carBrands);</pre><pre><em>// expected output: Array [&quot;Toyota&quot;, &quot;Nissan&quot;]</em></pre><p>I think now you have an idea how a <strong><em>map()</em></strong> method works. Let’s move into the next method.</p><h4>02. filter( )</h4><p>This method looks similar to the <strong><em>map()</em></strong> method. But with this function, you can give a condition/criteria and it will return a new array that falls under the given condition/criteria. Take a look at the below code snippet and you can understand the behavior of the <strong><em>filter()</em></strong> method.</p><pre>const names = [&quot;James&quot;, &quot;Freddie&quot;, &quot;Johnson&quot;, &quot;Nelson&quot;, &quot;Jenny&quot;, &quot;George&quot;];</pre><pre>const result = names.filter((name) =&gt; {<br><em>return</em> name.length &gt; 6;<br>});</pre><pre>console.log(result);</pre><pre><em>// expected output: Array [&quot;Freddie&quot;, &quot;Johnson&quot;]</em></pre><p>What happens in the above code snippet is it filters out the <em>“names”</em> array under the condition of <em>“name.length &gt; 6”</em>. So, inside the method, it checks each value and returns the values that satisfy the given condition. Pretty straightforward, right? Let’s move on.</p><h4>03. forEach( )</h4><p>I’m sure that you know the <strong><em>for</em></strong> loop. If I say this is the simplest type of for loop, I think you’ll agree with me after getting to know about this method. So, take a look at the given code snippet.</p><pre>const array = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;];</pre><pre>array.forEach((element) =&gt; console.log(element));</pre><pre><em>// expected output: &quot;a&quot;<br>// expected output: &quot;b&quot;<br>// expected output: &quot;c&quot;</em></pre><p>When using the <strong><em>forEach()</em></strong> method, it executes a provided function once for each array element.</p><h4>04. find( )</h4><p>Using this method you can find a single object in an array. It also takes a single function with a given name as the parameter. All we do is we have a true or false statement and it returns the item for the first one where it’s true. Take a look at the below code snippet</p><pre>const cars = [</pre><pre>{ brand: &quot;Toyota&quot;, model: &quot;axio&quot; },</pre><pre>{ brand: &quot;Nissan&quot;, model: &quot;GTR R35&quot; },</pre><pre>];</pre><pre>const carBrands = cars.find((car) =&gt; {</pre><pre><em>return</em> car.brand === &quot;Nissan&quot;;</pre><pre>});</pre><pre>console.log(carBrands);</pre><pre><em>// expected output: Object { brand: &quot;Nissan&quot;, model: &quot;GTR R35&quot; }</em></pre><p>I think now you have a clear idea about the <strong><em>find()</em></strong> method. But there’s one thing to remember. If there’s a key, value pair with same key or value, this method doesn’t return all the objects. It only returns the object that is true.</p><h4>05. every( )</h4><p>Using this method, you can check the array with some condition. What does that mean is you can give a condition and <strong><em>every()</em></strong> method checks to make sure every single item falls under that. Then as the result, it returns the true or false .</p><pre>const books = [</pre><pre>{ name: &quot;book 01&quot;, price: 500 },</pre><pre>{ name: &quot;book 02&quot;, price: 100 },</pre><pre>{ name: &quot;book 03&quot;, price: 400 },</pre><pre>{ name: &quot;book 04&quot;, price: 700 },</pre><pre>{ name: &quot;book 05&quot;, price: 200 },</pre><pre>{ name: &quot;book 06&quot;, price: 600 },</pre><pre>];</pre><pre>const hasCheaperBooks = books.every((book) =&gt; {</pre><pre><em>return</em> book.price &lt;= 400;</pre><pre>});</pre><pre>console.log(hasCheaperBooks);</pre><pre><em>//expected output: false</em></pre><p>As the name of the method, this checks every single item that satisfies the given condition. Since there are books greater than 400, this method will return false as the output. The next array method is very similar to this method. So… let’s take a look at what it is all about.</p><h4>06. some( )</h4><p>In the <strong><em>every()</em></strong> method it checks the every single item that satisfies the given condition and it returned true or false . When it comes to <strong><em>some()</em></strong> method, as the name of the method it checks if some of the items in the array satisfy the given condition and return true or false . Take a look at the same example we used in <strong><em>every()</em></strong> function and see how it changes when it comes to <strong><em>some()</em></strong> method.</p><pre>const books = [</pre><pre>{ name: &quot;book 01&quot;, price: 500 },</pre><pre>{ name: &quot;book 02&quot;, price: 100 },</pre><pre>{ name: &quot;book 03&quot;, price: 400 },</pre><pre>{ name: &quot;book 04&quot;, price: 700&quot; },</pre><pre>{ name: &quot;book 05&quot;, price: 200 },</pre><pre>{ name: &quot;book 06&quot;, price: 600 },</pre><pre>];</pre><pre>const hasCheaperBooks = books.some((book) =&gt; {</pre><pre><em>return</em> book.price &lt;= 400;</pre><pre>});</pre><pre>console.log(hasCheaperBooks);</pre><pre><em>//expected output: true</em></pre><p>The output of the example is true because it does have books less than or equal to 400. In simple terms, it just checks the array to see if anything in the array returns true for the given condition. If it does, the entire thing returns true .</p><h4>07. reduce( )</h4><p>This method is a little bit different than all of the other methods since it’s actually doing some operation on the array and returning a combination of all those different operations. You may find this method is a little bit confusing to understand🤨, but I’ll explain in the simplest way I can.</p><p>The <strong><em>reduce()</em></strong> method takes a function and it has two parameters. 1st one is the <strong>previousValue </strong>. 2nd one is <strong>currentValue </strong>. Finally, end of the method there is <strong>initialValue </strong>. Take a look at the below code snippet and you will understand this confusing explanation.</p><pre>const books = [</pre><pre>{ name: &quot;book 01&quot;, price: 500 },</pre><pre>{ name: &quot;book 02&quot;, price: 100 },</pre><pre>{ name: &quot;book 03&quot;, price: 400 },</pre><pre>{ name: &quot;book 04&quot;, price: 700 },</pre><pre>{ name: &quot;book 05&quot;, price: 200 },</pre><pre>{ name: &quot;book 06&quot;, price: 600 },</pre><pre>];</pre><pre>const total = books.reduce((currentTotal, book) =&gt; {</pre><pre><em>return</em> book.price + currentTotal;</pre><pre>}, 0);</pre><pre>console.log(total);</pre><pre><em>//expected output: 2500</em></pre><p>You can see the initial value of the currentTotal is 0. In the 1st iteration, 500 will be added to the 0. Then the currentTotal will be 500. Like that it will run until the end of the array. Then it’ll return the final output as 2500.</p><h4>08. includes( )</h4><p>The <strong><em>includes()</em></strong> method determines whether a given array includes a certain value among its entries, returning true or false as appropriate. It’s not similar to all the methods that I mentioned earlier in this article. This doesn’t take a function, it takes a single argument. Referring to code snippet, you can understand what happens when you use the <strong><em>includes()</em></strong> method.</p><pre>const array = [1, 2, 3];</pre><pre>console.log(array.includes(3));<br>// expected output: true</pre><pre>const pets = [&#39;cat&#39;, &#39;dog&#39;, &#39;parrot&#39;];</pre><pre>console.log(pets.includes(&#39;dog&#39;));<br>// expected output: true</pre><pre>console.log(pets.includes(&#39;pig&#39;));<br>// expected output: false</pre><p>I think the code snippet describes the behavior of the <strong><em>includes()</em></strong> method because it’s easier than previously describes methods😉.</p><p>I hope you have learned something interesting and got an idea about the methods I discussed in this article. So, until next time, stay safe!!!😎.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbed2574ca5d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ms-club-of-sliit/8-must-know-javascript-array-methods-cbed2574ca5d">8 must know JavaScript array methods.</a> was originally published in <a href="https://medium.com/ms-club-of-sliit">MS Club of SLIIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with ‘Git’]]></title>
            <link>https://medium.com/ms-club-of-sliit/getting-started-with-git-121a2488e44?source=rss-239052e48928------2</link>
            <guid isPermaLink="false">https://medium.com/p/121a2488e44</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[version-control-system]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Kaveen Laksitha]]></dc:creator>
            <pubDate>Wed, 10 Nov 2021 06:52:08 GMT</pubDate>
            <atom:updated>2021-11-10T06:52:08.527Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*-rvEM4zPv8Sgr8VrMiEBqg.png" /></figure><p>Introduction to git and GitHub</p><h4>Prerequisites</h4><ol><li><a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Install git</a>.</li><li><a href="https://github.com/join">Create an account on GitHub</a>.</li></ol><p><em>You can ignore this if you have already installed git and have an account on GitHub.</em></p><h4>Introduction</h4><p>Hello, everyone! I hope you&#39;re doing well. From this article, I will explain how to use git in your project while talking about other things which are related to this topic.</p><p>When you are doing a project with your friends or with your teammates, maybe you used to save your project with different versions and share your source with others through emails, USB drives, etc. And when your project is completed and needs to integrate it, you may be doing it by copying other people’s code and pasting it into the relevant files. But there is a way to do all those things via a version control system. From this article, I will explain how to use git in your project while talking about other things which are related to this topic.</p><p>Now you are wondering what is a version control system?. Basically, Version control is a way to save changes over time without overwriting previous versions. You can read more about version control by visiting this <a href="https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control">link</a>. There are many version control systems out there. But ‘git’ is extremely popular and It has some major advantages.</p><p>Git is a free and open-source distributed version control system that was developed back in 2005. Compared to other version control systems, git is responsive and easy to use. Once you are familiar with using git, you will agree with me if I say “git” is the kind of a life savior of developers😎.</p><h4>Git and GitHub</h4><p>Even though git and GitHub both sound like same, they are different. I already talked above about git. It is a distributed version control system. But ‘GitHub’ is a cloud-based hosting service that lets you manage git repositories. You don’t need GitHub to use git, but you cannot use GitHub without using git.</p><h4>Let’s get started!</h4><p>Now let’s see how to use git to do version control. I think you have installed git on your computer. To use git, you have to open the windows command prompt, Git Bash, or terminal on your IDE.</p><p>Now let’s tell Git about your name and email.</p><pre>git config --global user.name “Your Name Comes Here”<br>git config --global user.email you@yourdomain.example.com</pre><p>In order to make sure git saved our configuration settings, we can use the following command.</p><pre>git config --list </pre><p>Alright, now we need to tell git which folder we want to initialize git. To do so, get the path of your project directory and type the below command on your terminal/ command prompt. It will change the working directory of your terminal/command prompt to your project directory.</p><pre>cd &lt;path-to-project-folder&gt;</pre><p>Okay, we have navigated to the project directory. Let’s initialize git in the project directory. The following command will do that.</p><pre>git init</pre><blockquote>If you want to create a new project directory with git configurations, use the following command</blockquote><pre>git init &lt;folder-name&gt;</pre><blockquote>You can contribute to an existing project by making a copy of the repository in your system. In simple terms, create a clone. You can use the following command to do that.</blockquote><pre>git clone &lt;remote-repository-URL&gt;</pre><p>Now you have initialized your project directory with git configurations. Before moving forward, you should know about four major areas in git. Look at the below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8Uj-uSvlQPNODq8VxEEUQ.png" /></figure><p><strong>01. Working Directory</strong></p><p>Your project directory. sometimes also called the “working tree”.</p><p><strong>02. Staging Area</strong></p><p>The staging area is a place to record things before committing.</p><blockquote>In Git, a commit is a snapshot of your repo at a specific point in time. Committing is the process that brings your changes to the local repository.</blockquote><p><strong>03. Local Repository</strong></p><p>The local repository is the one on which we will make local changes, typically this local repository is on our computer.</p><p><strong>04. Remote Repository</strong></p><p>A remote repository in Git, also called a remote, is a Git repository that’s hosted on the Internet or another network.</p><p>Alright, let’s get back to our topic. We have already initialized your project directory with git configurations. Let’s add a remote repository connection by the following command.</p><pre>git remote add &lt;remote-name&gt; &lt;remote-repository-url&gt;</pre><blockquote>I think you know how to get the URL of the central repository. If you don’t want to use a remote repository, you can ignore this step. But it’s not preferred.</blockquote><p>In order to tell git which files you want to stage, you can follow the below command.</p><pre>git add &lt;file-name&gt;</pre><p>Following the below command you can add all changed/ edited to the staging area.</p><pre>git add --all</pre><p>or</p><pre>git add -A</pre><p>Now your files are in the staging area. In order to bring those files to the local repository, you have to commit(mentioned above) your changes by using the below command.</p><pre>git commit -m “&lt;commit-message&gt;”</pre><blockquote>When it comes to a commit message, you can use any message as a commit message. But try to provide a meaningful message which belongs to your commit.</blockquote><p>Whoo! now your files are safe in the local repository. But we have not pushed those files to the remote repository yet. We can do it by using the below command.</p><pre>git push &lt;remote-name&gt; &lt;branch-name&gt;</pre><p>You already know what is the remote name is. But what is this &lt;branch-name&gt;?. Before getting to know about branch name, you have to know what is a branch. A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is ‘master’. This default branch is created on the point we have initialized our project directory(remember the <strong><em>git init</em></strong>?). If you want to create another branch you have to use the below command.</p><pre>git branch &lt;branch-name&gt;</pre><p>After you create a new branch, you have to checkout to that branch in order to work there. you can do it by the following command.</p><pre>git checkout &lt;branch-name&gt;</pre><p>There is another command to do above both things at once.</p><pre>git checkout -b &lt;branch-name&gt;</pre><p>Ok 😂. Let’s resume from the point which I’ve paused. Where were we? Ah, I remember… We have pushed our commits to the remote repository. Now other teammates or collaborators of your project can use the changes you made. What if other teammates or collaborators make changes to the project and they have pushed their changes to the remote repository. How are you going to get those changes to your working directory?🤔. Simply you have to do it type the following command.</p><pre>git pull &lt;remote-name&gt; &lt;branch-name&gt;</pre><p>The above command will fetch the modified remote repository to your local repository and then merge it to the branch that you are currently in. If you have any doubts about what we have done so far, you can understand them by referring to the bellow figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-RGaakJvM5QT-nThX2IdA.png" /><figcaption>Figure 02</figcaption></figure><p>And that’s it! Now you can use git in your project to do the proper version control while saving your time and life😉.</p><h4>Something little extra for you</h4><p>When cloning a git repository that you have <strong>forked</strong>, you can add another remote named <strong>upstream </strong>in order to keep track of the original repository. It will sync changes you make, with the original repository.</p><p>First of all, we can list the URLs of the current configured remote repository using the below command on cmd/ terminal.</p><pre>git remote -v</pre><p>If there are no upstream branches, you can create an upstream branch by using the below command.</p><pre>git remote add upstream &lt;remote-repository-url&gt;</pre><p>Then you can collect the latest changer of the upstream repository with the below command. Repeat this every time you want to get updates.</p><pre>git fetch upstream</pre><p>After that, you can merge those changes with your branch by using the following command.</p><pre>git checkout &lt;branch-name&gt;</pre><pre>git merge upstream/&lt;branch-name&gt;</pre><p>Those things may be a little bit confused for you. But this will be helpful when you are working with git.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=121a2488e44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ms-club-of-sliit/getting-started-with-git-121a2488e44">Getting started with ‘Git’</a> was originally published in <a href="https://medium.com/ms-club-of-sliit">MS Club of SLIIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a REST API and how does it work?]]></title>
            <link>https://medium.com/ms-club-of-sliit/what-is-an-api-and-how-does-it-work-4cef84e91fd9?source=rss-239052e48928------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cef84e91fd9</guid>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Kaveen Laksitha]]></dc:creator>
            <pubDate>Fri, 30 Jul 2021 05:56:18 GMT</pubDate>
            <atom:updated>2021-07-31T14:19:15.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*BegxnIx9JhW2uveBx_mBBA.png" /></figure><h4>Introduction to API</h4><p>API… I think you heard this word a lot. But maybe you don’t know what it is and want to know about it. When I heard it for the first time, I was also had eager to know what is it. So In this article, I’ll try to explain the concept behind API in a simple way as I got it.</p><p><strong>What is an API?</strong></p><p>First talk about what actually is an API. API stands for “<strong>A</strong>pplication <strong>P</strong>rogramming <strong>I</strong>nterface”. An API is essentially a set of rules that allows two applications to talk to each other. In a simple way, API is the messenger that takes your request and delivers it to the provider and delivers back the response of the provider to you. It acts as a communication bridge between the client application and server application.</p><p><strong>Process of API</strong></p><p>Let’s take a simple example to explain components and the process of an API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WgmpF7ra1SlkkKuuQGstTw.png" /><figcaption>Figure 01: Process of API(example)</figcaption></figure><p>Imagine the process happening when you purchasing some food from your favorite fast food outlet. You visit the outlet and place the order through the cashier. Then cashier takes your order to the kitchen. After your order is ready, the cashier brings back the food whatever you ordered.</p><p>When we use that example to explain the components and process of an API, the person who is placing an order is acting as the client or the application. The kitchen where process your request or the order and return the order acts as the server-side. Cashier of the outlet act as the API who takes your order and gives back the order to your request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDZteeRlyfkP_jfgWRLh0A.png" /><figcaption><strong>Figure 02</strong>: Process of API</figcaption></figure><p><strong>A little bit more about API</strong></p><p>When it comes to programming, communication between the client and the server is done using formats called “JSON” and “XML”. The usage of them depends on the API type. If you don’t know about JSON and XML, you can get an idea about JSON by visiting this <a href="https://www.json.org/json-en.html">link</a>, and by visiting this <a href="http://xml.silmaril.ie/basics.html">link </a>you can get an idea about XML.</p><p>There are some basic request methods that can be made with API.</p><p>1.<strong>GET </strong>— Retrieve data from a server at the specified resource</p><p>2.<strong>POST </strong>— Create a resource</p><p>3.<strong>PUT </strong>— Update or create a resource</p><p>4.<strong>PATCH </strong>— Only apply partial modifications to the resource</p><p>5.<strong>DELETE </strong>— It really does what it looks like ):</p><p>API plays an important role when it comes to software development. Software developers can use available APIs in their development process, instead of coding from the scratch. This leads to saving time on writing new programs while speeding up the development process.</p><p>You can learn more about APIs from <a href="https://www.redhat.com/en/topics/api/what-are-application-programming-interfaces">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cef84e91fd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ms-club-of-sliit/what-is-an-api-and-how-does-it-work-4cef84e91fd9">What is a REST API and how does it work?</a> was originally published in <a href="https://medium.com/ms-club-of-sliit">MS Club of SLIIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>