<?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 Hansaka Dilshan Jayawardana on Medium]]></title>
        <description><![CDATA[Stories by Hansaka Dilshan Jayawardana on Medium]]></description>
        <link>https://medium.com/@hansakadilshanjayawardana?source=rss-844f07119a2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ee2B59mstE7uuU8kxb3z7w.jpeg</url>
            <title>Stories by Hansaka Dilshan Jayawardana on Medium</title>
            <link>https://medium.com/@hansakadilshanjayawardana?source=rss-844f07119a2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:58:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hansakadilshanjayawardana/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[Spring Boot Tutorial Part One (Introduction)]]></title>
            <link>https://medium.com/@hansakadilshanjayawardana/spring-boot-tutorial-part-one-introduction-2aeeb46c5bd2?source=rss-844f07119a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2aeeb46c5bd2</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hansaka Dilshan Jayawardana]]></dc:creator>
            <pubDate>Mon, 12 Dec 2022 21:47:22 GMT</pubDate>
            <atom:updated>2022-12-12T21:49:09.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*4ZPi1b_ca54pUE9xRB-IFQ.jpeg" /></figure><h3>What is Spring Boot?</h3><p>Spring Boot is a fantastic platform for Java developers to create a stand-alone, production-grade spring application that can be started straight away. You may get started with only a few settings rather than a full Spring configuration.</p><p>The Java Spring Framework (Spring Framework) is a popular open-source enterprise framework for developing standalone, production-grade Java Virtual Machine applications (JVM).</p><p>Through three essential functionalities, Java Spring Boot (Spring Boot) helps develop a web application and microservices using Spring Framework faster and easier:</p><ul><li>Autoconfiguration</li><li>An opinionated approach to configuration</li><li>The ability to create standalone applications</li></ul><h3>Benefits of Using Spring Boot</h3><ul><li><strong>Reduce the Development Time</strong></li><li><strong>Reduce the Time Spent on Development and Increase the Overall Efficiency of the Development Team</strong></li><li><strong>Help to Autoconfiguration All Components for a Production-grade Spring App</strong></li><li><strong>Facilitate the Creation and Testing of Java-based Applications by Providing a Default Setup for Unit and Integration Tests</strong></li><li><strong>Help Avoid All the Manual Work of Writing Boilerplate Code, Annotations, and Complex XML Configurations</strong></li><li><strong>Come with Embedded HTTP Servers like Jetty and Tomcat to Test Web Applications</strong></li><li><strong>The Integration of Spring Boot with the Spring Ecosystem Which Includes Spring Data, Spring Security, Spring ORM, and Spring JDBC is Easy</strong></li><li><strong>Provide Many Plugins That Developers can Use to Work With Embedded and In-memory Databases Smoothly and Readily</strong></li><li><strong>Allow for Easily Connecting With Database and Queue Services like Oracle, PostgreSQL, MySQL, MongoDB, Redis, Solr, ElasticSearch, Rabbit MQ, ActiveMQ, and Many More</strong></li><li><strong>Provide Admin Support</strong></li><li><strong>Ease the Dependency and Come With Embedded Servlet Container</strong></li><li><strong>Offer Flexibility in Configuring XML Configurations, Java Beans, and Database Transaction</strong></li><li><strong>Offer Easy Access to Command Line Interface Which Make the Development and Testing of Spring Boot Apps Built With Java or Groovy Agile</strong></li><li><strong>Large Community and Many Training Programs to Facilitate the Familiarization Period</strong></li><li><strong>Simple Setup and Management</strong></li><li><strong>Easy Start</strong></li><li><strong>Additionally out-of-the-box Functionality</strong></li><li><strong>Reduce Amounts of Source Code</strong></li><li><strong>The Ability to Create Standalone Applications</strong></li><li><strong>No Need for the Deployment of war Files</strong></li></ul><h3>Disadvantages of Using Spring Boot</h3><ul><li><strong>Lack of control. Spring Boot creates a lot of unused dependencies, resulting in a large deployment file</strong></li><li><strong>The complex and time-consuming process of converting a legacy or an existing Spring project to a Spring Boot application</strong></li><li><strong>Not suitable for large-scale projects</strong></li><li><strong>If you have never worked with Spring before and want to learn about proxies, dependency injection, and AOP programming, it is not recommended to start with Spring Boot because it doesn’t cover most of these details</strong></li><li><strong>Since the framework has been built to be agile and lightweight mainly focusing on APIs and microservices to be built using the framework, therefore it should not be used for monolithic applications</strong></li><li><strong>You really have to understand a lot of the underlying Spring systems (and a bit of Spring history too), along with some advanced topics in order to modify and troubleshoot it</strong></li><li><strong>Spring Boot works well with microservices. The Spring Boot artifacts can be deployed directly into Docker containers. However, some developers don’t recommend the framework for building large and monolithic apps</strong></li><li><strong>If you are not familiar with other projects of the Spring ecosystem like Spring Security, Spring AMQP, Spring Integration, etc.), using them with Spring Boot will make you miss many concepts that you would grasp if you had started using them independently</strong></li></ul><h3>Features of Spring Boot</h3><ul><li><strong>Web Development: </strong>It is a great Spring module for developing web applications. Using embedded Tomcat, Jetty, or Undertow, we can simply develop a self-contained HTTP server. The spring-boot-starter-web module may be used to quickly start and operate the application.</li><li><strong>SpringApplication: </strong>It is a class that makes it simple to start a Spring application from the main method. Simply using the static run() method will launch your program.</li><li><strong>Application Events and Listeners: </strong>Spring Boot handles a number of tasks through events. It enables us to construct a factories file for adding listeners. The ApplicationListener key can be used to refer to it.</li><li><strong>Admin Features: </strong>Spring Boot allows you to enable administrative functions for your application. It is used to remotely access and administer applications. The spring.application.admin.enabled property may be used to enable it.</li><li><strong>Externalized Configuration: </strong>We may externalize our configuration with Spring Boot, allowing us to operate with the same application in different environments. To externalize configuration, the application uses YAML files.</li><li><strong>Properties Files: </strong>Application Properties are abundant in Spring Boot. As a result, we may utilize that in our project’s properties file. Property values such as <strong>server-port = 8082</strong> and others are set in the properties file. It aids in the organization of application properties.</li><li><strong>YAML Support: </strong>It provides convenient way for specifying hierarchical configuration. It is a superset of JSON. The SpringApplication class automatically support YAML. It is successful alternative of properties.</li><li><strong>Type-safe Configuration: </strong>Strong type-safe configuration is provided to govern and validate the configuration of application. Application configuration is always a crucial task which should be type-safe. We can also use annotation provided by this library.</li><li><strong>Logging: </strong>Spring Boot uses Common logging for all internal logging. Logging dependencies are managed by default. We should not change logging dependencies, if there is no required customization is needed.</li><li><strong>Security: </strong>Spring Boot applications are spring bases web applications. So, it is secure by default with basic authentication on all HTTP endpoints. A rich set of Endpoints are available for develop a secure Spring Boot application.</li></ul><h3>Goals of Spring Boot</h3><ul><li><strong>To provide a radically faster and widely accessible ‘getting started’ experience for all Spring development</strong></li><li><strong>To be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults</strong></li><li><strong>To provide a range of non-functional features that are common to large classes of projects (e.g., embedded servers, security, metrics, health checks, externalized configuration)</strong></li><li><strong>To avoid complex XML configuration in Spring</strong></li><li><strong>To reduce the development time and run the application independently</strong></li><li><strong>Offer an easier way of getting started with the application</strong></li></ul><h3>Performance</h3><ul><li><strong>Component Scanning Slows Start-up: </strong>You may find yourself utilizing the @SpringBootApplication annotation by default to automatically configure your application. This has a handful of negative consequences. One is to make <strong>component scanning</strong> possible. This searches the classes for annotations like @Component, which are Spring “stereotypes.” This is handy, especially at first, but it has two negative consequences: It slows application start-up time. This will have a greater impact if you have a large application or a large number of integration tests that need to start up the application to run. It may load beans you do not want or need. Remove the @SpringBootApplication and @ComponentScan annotations to prevent component scanning. Then, in your setup, you’ll need to make each bean explicit.</li><li><strong>Auto-Configuration Can Load More Than You Need</strong></li><li><strong>Change Servlet Container to Undertow</strong></li></ul><p>That concludes part one of this Spring Boot tutorial. We’ve looked at Spring Boot briefly in this blog. If you want to learn more about Spring Boot, visit its <a href="https://spring.io/projects/spring-boot">website</a>, find it on <a href="https://github.com/spring-projects/spring-boot">Github</a> or check out this repository of <a href="https://github.com/spring-projects/spring-data-jpa">examples</a>.</p><p>In the next part of this tutorial, we’ll learn more about Spring Boot and how to build a CRUD application. Leave a comment below if you have any questions or comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2aeeb46c5bd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ReactJS Tutorial Part One (Introduction)]]></title>
            <link>https://medium.com/@hansakadilshanjayawardana/reactjs-tutorial-part-one-introduction-55b1d47d0fd0?source=rss-844f07119a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/55b1d47d0fd0</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Hansaka Dilshan Jayawardana]]></dc:creator>
            <pubDate>Mon, 12 Dec 2022 21:19:56 GMT</pubDate>
            <atom:updated>2022-12-12T21:19:56.112Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*ABVZa5V57pojP-XeCzhb0g.jpeg" /></figure><h3>What is ReactJS?</h3><p>ReactJS is now one of the most popular JavaScript front-end libraries, with a huge community and a solid basis.</p><p>ReactJS is a <strong>JavaScript library</strong> for creating reusable UI components that are <strong>declarative</strong>, <strong>efficient</strong>, and <strong>versatile</strong>. It is a component-based open-source front-end library that exclusively handles the application’s view layer. Facebook created and managed it at first, and it was eventually integrated into its products such as WhatsApp and Instagram.</p><p>All of the topics that help you understand ReactJS are covered in our ReactJS blog series. ReactJS Introduction, ReactJS Features, ReactJS Installation, ReactJS Pros and Cons, ReactJS JSX, ReactJS Components, ReactJS State, ReactJS Props, ReactJS Forms, ReactJS Events, ReactJS Animation, and many others are among them.</p><h3>Benefits of Using ReactJS</h3><ul><li><strong>Speed: </strong>Developers may use separate components of their application on both the client-side and the server-side with React, which speeds up the development process. Simply put, various developers can create separate areas of the program, and any modifications made will not affect the application’s logic.</li><li><strong>Flexibility: </strong>React code is easier to maintain and more flexible than other frontend frameworks because of its modular nature. Businesses save a significant amount of time and money as a result of this flexibility.</li><li><strong>Performance: </strong>React JS was designed with excellent performance in mind. The framework’s key features include a virtual DOM program and server-side rendering, allowing complicated projects to execute exceptionally quickly.</li><li><strong>Usability: </strong>If you have a basic knowledge of JavaScript, deploying React is quite simple. In just a day or two, an experienced JavaScript developer can learn everything there is to know about the React framework.</li><li><strong>Reusable Components: </strong>One of the key advantages of React JS is the ability to reuse components. Developers save time since they don’t have to build many codes for the same functionalities. Furthermore, any modifications made to one section of the program will not affect other portions.</li><li><strong>Mobile Application Development: </strong>If you think React is exclusively for web development, you’re completely incorrect! Facebook has already updated its framework for creating native mobile apps for both Android and iOS.</li><li><strong>Easy to Learn</strong></li><li><strong>Help to Build Rich User Interfaces</strong></li><li><strong>Allow Writing Custom Components</strong></li><li><strong>Uplift Developers’ Productivity</strong></li><li><strong>Offer Fast Rendering</strong></li><li><strong>SEO-Friendly</strong></li><li><strong>Come with a Useful Developer Toolset</strong></li><li><strong>Strong Community Support</strong></li><li><strong>Offer Better Code Stability</strong></li><li><strong>Used by Many Fortunes 500 Companies</strong></li><li><strong>Proficient Data Binding</strong></li><li><strong>Extend Your Tools and Capacities</strong></li><li><strong>Testing and Functionality</strong></li><li><strong>UI-focused Design</strong></li><li><strong>Provide a Unique Abstraction Layer</strong></li><li><strong>Template Designing Made Easy</strong></li></ul><h3>Disadvantages of Using ReactJS</h3><ul><li><strong>The High Pace of Development: </strong>The high pace of development has both benefits and drawbacks. In the event of a disadvantage, because the environment is always changing, some developers may not feel comfortable relearning new ways of doing things frequently. With all the constant upgrades, it may be difficult for them to absorb all of these changes. They must keep their abilities up to date and learn new methods of doing things.</li><li><strong>Poor Documentation: </strong>Another disadvantage of continuously changing technology is this. React technologies are evolving and developing at such a rapid pace that there is no time to make proper documentation. To get around this, developers write their instructions as new versions and tools appear in their existing projects.</li><li><strong>View Part: </strong>React comes with a variety of tools for developing and designing user interfaces. ReactJS, unlike frameworks, is not an all-in-one app development solution. If you adopt a model-view-controller (MVC) architecture, ReactJS development is just responsible for the user interface. Other tools must be used by the developers to generate the model and controller. To construct a working application, you will need to use additional tools to handle other important aspects like the backend and data storage. Additional tools will be required for app programming interfaces (APIs), routing, and other elements.</li><li><strong>JSX as a Barrier: </strong>ReactJS uses JavaScript XML (JSX), which is an XML or HTML-like JavaScript syntax extension. It enhances ES6 by being processed into React Framework JavaScript calls. This allows HTML-like text and JavaScript react code to coexist. However, because of the learning curve’s intricacy, it also operates as a barrier.</li><li><strong>Incomplete Tooling Set: </strong>Businesses should be aware that React’s scope is limited to the application’s UI layer. Everything else linked to the web development project is outside of its scope. As a result, even after applying React web app development, developers must still select a framework to create a fast, attractive and suitable user interface. The developers will have difficulty finishing the project because the whole tools set is not available solely with React.</li><li><strong>Limitations of React Being a Library</strong></li><li><strong>Creating a Long List Item</strong></li><li><strong>Difficult Learning Curve</strong></li><li><strong>Excessive Freedom and Verbose Code</strong></li><li><strong>Staying Up to Date can be Built</strong></li><li><strong>Highly Expensive</strong></li></ul><h3>Features of ReactJS</h3><ul><li><strong>JSX (JavaScript Syntax Extension): </strong>HTML and JavaScript are combined in JSX. JavaScript objects can be inserted into HTML elements. Because browsers do not support JSX, the code is trans compiled into JavaScript using the Babel compiler. JSX makes coding simple and straightforward. Knowing HTML and JavaScript makes it simple to learn.</li><li><strong>Virtual DOM: </strong>Document Object Model stands for Document Object Model. It is the most crucial aspect of the web since it splits the code into modules and executes it. JavaScript Frameworks often update the whole DOM at once, making the online application sluggish. However, react makes use of virtual DOM, which is a carbon replica of actual DOM. When a web application is modified, the virtual DOM is updated first, and the difference between the real DOM and the virtual DOM is determined. When it discovers the difference, DOM just updates the parts that have changed recently, leaving the rest unchanged.</li><li><strong>One-way Data Binding: </strong>One-way data binding is a one-direction flow, as the name implies. In react, data only travels in one direction: from top to bottom, from parent components to child components. The child component’s properties (props) cannot return data to its parent component, but they can communicate with it to change the states based on the inputs. One-way Data Binding operates in this manner. Everything remains modular and quick as a result.</li><li><strong>Performance: </strong>As previously mentioned, react makes use of a virtual DOM and only updates the portions that have changed. As a result, the DOM runs quicker. Because the DOM runs in memory, we can design independent components that speed up the DOM.</li><li><strong>Extension: </strong>We can leverage React’s extensions to build full-featured UI apps. It allows for the creation of mobile apps and server-side rendering. Flux, Redux, React Native, and other extensions to React allow us to design attractive user interfaces.</li><li><strong>Conditional Statements</strong></li><li><strong>Component Based Architecture</strong></li><li><strong>Simplicity</strong></li><li><strong>Declarative UI</strong></li><li><strong>React Native</strong></li></ul><h3>Installation</h3><h4>Prerequisites</h4><ul><li>NodeJS and NPM</li><li>React and React DOM</li><li>Webpack</li><li>Babel</li></ul><h4>How to Install ReactJS on Windows Using the npm Command</h4><h4>Step 1: Install NodeJS and NPM</h4><p>You can read previous <a href="https://medium.com/@hansakadilshanjayawardana/nodejs-tutorial-part-one-introduction-854f0f30efd7">NodeJS blog</a> and can get knowledge how to install NodeJS and NPM.</p><h4>Step 2: Create the Root Folder</h4><p>Create a folder with name <strong>reactApp</strong> on the desktop to install all the required files, using the mkdir command.</p><pre>C:\Users\HansakaDilshan\Desktop&gt;mkdir reactApp<br>C:\Users\HansakaDilshan\Desktop&gt;cd reactApp</pre><p>To create any module, it is required to generate the <strong>package.json</strong> file. Therefore, after Creating the folder, we need to create a <strong>package.json</strong> file. To do so you need to run the <strong>npm init</strong> command from the command prompt.</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm init</pre><p>This command asks information about the module such as packagename, description, author etc. you can skip these using the –y option.</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm init -y<br>Wrote to C:\reactApp\package.json:<br>{<br> “name”: “reactApp”,<br> “version”: “1.0.0”,<br> “description”: “”,<br> “main”: “index.js”,<br> “scripts”: {<br> “test”: “echo \”Error: no test specified\” &amp;&amp; exit 1&quot;<br> },<br> “keywords”: [],<br> “author”: “”,<br> “license”: “ISC”<br>}</pre><h4>Step 3: Install React and React DOM</h4><p>Since our main task is to install ReactJS, install it, and its dom packages, using <strong>install react</strong> and <strong>react-dom</strong> commands of npm respectively. You can add the packages we install, to <strong>package.json</strong> file using the <strong>— save</strong> option.</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install react - save<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install react-dom - save</pre><p>Or you can install all of them in single command as –</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install react react-dom - save</pre><h4>Step 4: Install Webpack</h4><p>Since we are using webpack to generate bundler install webpack, webpack-dev-server and webpack-cli.</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install webpack - save<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install webpack-dev-server - save<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install webpack-cli - save</pre><p>Or you can install all of them in single command as –</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install webpack webpack-dev-server webpack-cli - save</pre><h4>Step 5: Install Babel</h4><p>Install babel, and its plugins babel-core, babel-loader, babel-preset-env, babel-preset-react and, html-webpack-plugin.</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install babel-core — save-dev<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install babel-loader — save-dev<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install babel-preset-env — save-dev<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install babel-preset-react — save-dev<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install html-webpack-plugin — save-dev</pre><p>Or you can install all of them in single command as –</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm install babel-core babel-loader babel-preset-env babel-preset-react html-webpack-plugin — save-dev</pre><h4>Step 6: Create the Files</h4><p>To complete the installation, we need to create certain files namely, index.html, App.js, main.js, webpack.config.js and, .<strong><em>babelrc</em></strong>. You can create these files manually or, using <strong>command prompt</strong>.</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;type nul &gt; index.html<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;type nul &gt; App.js<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;type nul &gt; main.js<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;type nul &gt; webpack.config.js<br>C:\Users\HansakaDilshan\Desktop\reactApp&gt;type nul &gt; .babelrc</pre><h4>Step 7: Set Compiler, Server and Loaders</h4><p>Open <strong>webpack-config.js</strong> file and add the following code. We are setting webpack entry point to be main.js. Output path is the place where bundled app will be served. We are also setting the development server to <strong>8001</strong> port. You can choose any port you want.</p><p><strong>webpack.config.js</strong></p><pre>const path = require(‘path’);<br>const HtmlWebpackPlugin = require(‘html-webpack-plugin’);<br>module.exports = {<br>  entry: ‘./main.js’,<br>  output: {<br>    path: path.join(__dirname, ‘/bundle’),<br>    filename: ‘index_bundle.js’<br>  },<br>  devServer: {<br>    inline: true,<br>    port: 8001<br>  },<br>  module: {<br>    rules: [<br>      {<br>        test: /\.jsx?$/,<br>        exclude: /node_modules/,<br>        loader: ‘babel-loader’,<br>        query: {<br>          presets: [‘es2015’, ‘react’]<br>        }<br>      }<br>    ]<br>  },<br>  plugins:[<br>    new HtmlWebpackPlugin({<br>      template: ‘./index.html’<br>    })<br>  ]<br>}</pre><p>Open the <strong>package.json</strong> and delete <strong>“test” “echo \”Error: no test specified\” &amp;&amp; exit 1&quot;</strong> inside <strong>“scripts”</strong> object. We are deleting this line since we will not do any testing in this tutorial. Let’s add the <strong>start</strong> and <strong>build</strong> commands instead.</p><pre>“start”: “webpack-dev-server — mode development — open — hot”,<br>“build”: “webpack — mode production”</pre><h4>Step 8: index.html</h4><p>This is just regular HTML. We are setting <strong>div id = “app”</strong> as a root element for our app and adding <strong>index_bundle.js</strong> script, which is our bundled app file.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang = &quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset = &quot;UTF-8&quot;&gt;<br>    &lt;title&gt;React App&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;div id = &quot;app&quot;&gt;&lt;/div&gt;<br>    &lt;script src = &#39;index_bundle.js&#39;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><h4>Step 9: App.jsx and main.js</h4><p>This is the first React component. We will explain React components in depth in a subsequent chapter. This component will render <strong>Hello World</strong>.</p><p><strong>App.js</strong></p><pre>import React, { Component } from &#39;react&#39;;<br>class App extends Component{<br>  render(){<br>    return(<br>      &lt;div&gt;<br>        &lt;h1&gt;Hello World&lt;/h1&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}<br>export default App;</pre><p>We need to import this component and render it to our root <strong>App</strong> element, so we can see it in the browser.</p><p><strong>main.js</strong></p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import App from &#39;./App.js&#39;;<br>ReactDOM.render(&lt;App /&gt;, document.getElementById(&#39;app&#39;));</pre><p><strong>Note</strong> − Whenever you want to use something, you need to <strong>import</strong> it first. If you want to make the component usable in other parts of the app, you need to <strong>export</strong> it after creation and import it in the file where you want to use it.</p><p>Create a file with name <strong>.babelrc</strong> and copy the following content to it.</p><pre>{<br> &quot;presets&quot;:[&quot;env&quot;, &quot;react&quot;]<br>}</pre><h4>Step 10: Run the Server</h4><p>The setup is complete, and we can start the server by running the following command.It will show the port we need to open in the browser. In our case, it is <a href="http://localhost:8001/"><strong>http://localhost:8001/</strong></a>.</p><h4>Step 11: Generate the Bundle</h4><p>Finally, to generate the bundle you need to run the build command in the command prompt as −</p><pre>C:\Users\HansakaDilshan\Desktop\reactApp&gt;npm run build</pre><h4>How to Install ReactJS on Windows Using the create-react-app Command</h4><h4>Step 1: Install NodeJS and NPM</h4><p>You can read previous <a href="https://medium.com/@hansakadilshanjayawardana/nodejs-tutorial-part-one-introduction-854f0f30efd7">NodeJS blog</a> and can get knowledge how to install NodeJS and NPM.</p><h4>Step 2: Install create-react-app</h4><p>Browse through the desktop and install the Create React App using command prompt as shown below −</p><pre>C:\Users\HansakaDilshan&gt;cd C:\Users\Tutorialspoint\Desktop\<br>C:\Users\HansakaDilshan\Desktop&gt;npx create-react-app my-app</pre><h4>Step 3: Delete All the Source Files</h4><p>Browse through the src folder in the generated my-app folder and remove all the files in it as shown below −</p><pre>C:\Users\HansakaDilshan\Desktop&gt;cd my-app/src<br>C:\Users\HansakaDilshan\Desktop\my-app\src&gt;del *<br>C:\Users\HansakaDilshan\Desktop\my-app\src\*, Are you sure (Y/N)? y</pre><h4>Step 4: Add Files</h4><p>Add files with names <strong>index.css</strong> and <strong>index.js</strong> in the src folder as −</p><pre>C:\Users\HansakaDilshan\Desktop\my-app\src&gt;type nul &gt; index.css<br>C:\Users\HansakaDilshan\Desktop\my-app\src&gt;type nul &gt; index.js</pre><p>In the index.js file add the following code:</p><pre>import React from ‘react’;<br>import ReactDOM from ‘react-dom’;<br>import ‘./index.css’;</pre><h4>Step 5: Run the Project</h4><p>Finally, run the project using the start command.</p><pre>npm start</pre><p>That concludes part one of this ReactJS tutorial. We’ve looked at ReactJS briefly in this blog. If you want to learn more about ReactJS, visit its <a href="https://reactjs.org/">website</a>, find it on <a href="https://github.com/reactjs">Github</a> or check out this repository of <a href="https://github.com/facebook/react">facebook</a>.</p><p>In the next part of this tutorial, we’ll learn more about React and how to build a CRUD application. Leave a comment below if you have any questions or comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55b1d47d0fd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB Tutorial Part One (Introduction)]]></title>
            <link>https://medium.com/@hansakadilshanjayawardana/mongodb-tutorial-part-one-introduction-e44bcb4b6194?source=rss-844f07119a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e44bcb4b6194</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Hansaka Dilshan Jayawardana]]></dc:creator>
            <pubDate>Tue, 29 Nov 2022 21:36:32 GMT</pubDate>
            <atom:updated>2022-11-29T21:45:16.788Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UFC4boq7Mx_XK7gsRLSUFg.png" /></figure><h3>What is MongoDB?</h3><p>MongoDB is a cross-platform, document-oriented database with excellent speed, high availability, and automatic scaling. MongoDB is based on the collection and document concepts. It is a NoSQL database. MongoDB is freely accessible under the GNU General Public License, and it is also available from the manufacturer under the Commercial license. MongoDB’s development began in 2007 when the business was developing a platform as a service comparable to Windows Azure.</p><h3>Benefits of Using MongoDB</h3><ul><li><strong>Full Cloud-Based Application Data Platform</strong>: MongoDB is not just a database; it is a lot more. It is a complete application data platform. With MongoDB Atlas, the cloud offered by MongoDB, you have access to a collection of services that all integrate nicely with your database. Amongst other things, you will have:</li></ul><ol><li>The Performance Advisor makes suggestions for improving the performance of your database.</li><li>Atlas Search is a full-text search engine based on the MongoDB Query API.</li><li>MongoDB Charts is a simple tool for creating beautiful dashboards and visualizations.</li><li>Multi-cloud deployment, which is provided out-of-the-box on any major cloud provider.</li></ol><ul><li><strong>Flexible Document Schemas: </strong>One of MongoDB’s most appealing advantages is its ability to derive a document-based data model. Because of the way it keeps data in the form of BSON (Binary JSON), ruby hashes, and other formats, it can store a lot of data while also holding arrays and other documents.</li><li><strong>Widely Supported and Code Native Access: </strong>To extract data into Object form for usage in programs, most databases require the use of heavy wrappers such as ORMs (Object-Relational Mappers). MongoDB’s decision to store and represent data in a document format implies that you may access it in any language, using native data structures (e.g., dictionaries in Python, objects in JavaScript, Maps in Java, etc.).</li><li><strong>Change-Friendly Design: </strong>If you’re used to having to bring down your site or application to change the structure of your data, you’re in luck: MongoDB is designed for change. We put a lot of work into designing efficient procedures and learning from our failures, but the database is usually a bottleneck. Changing schemas does not need any downtime, and you may start writing new data to MongoDB at any moment without interrupting its operations.</li><li><strong>Easy Horizontal Scale-Out with Sharding: </strong>One of its primary features is support for Sharding. Shardingrefers to the technique of storing data across several machines and MongoDB’s capacity to handle data as it grows in size. Horizontal scaling is the outcome of this. When Sharding is used, a larger amount of data may be written and read back as the amount of data grows.</li><li><strong>High Performance (Speed): </strong>MongoDB is a document-oriented database. It is easy to access documents by indexing. Hence, it provides fast query response. The speed of MongoDB is 100 times faster than the relational database.</li><li><strong>Simple Installation: </strong>Creating and configuring a MongoDB cluster is easier than ever using MongoDB Atlas. You may create a new forever-free instance with only a few clicks in the user-friendly interface. You’ll be able to connect to your database using the given connection string in minutes. There are a variety of methods to get started with MongoDB on your hardware. The community or enterprise editions can be installed directly on a server. You may also build your own MongoDB container or utilize a pre-built community one.</li><li><strong>Cost-Effective: </strong>MongoDB provides a variety of versatile options. When using MongoDB Atlas in the cloud, you may select the instance size that best suits your needs. You may also configure your cluster to scale automatically as needed. In this manner, you can keep your expenditure low while yet being able to deal with unexpected traffic jams. You may now establish Serverless Databases in addition to the cost flexibility of dedicated clusters. You will only be paid for the actual usage of these databases, making them incredibly flexible and ideal for many low consumptions use cases.</li><li><strong>MongoDB has No Joins: </strong>In RDBMS, connecting two or more tables is challenging as it requires using joins. MongoDB has no complex joins, and changing the document structure in MongoDB is easy, allowing us to connect to other documents with no difficulty.</li><li><strong>No Primary Key Set-Up: </strong>When using RDBMS, setting up a primary key is necessary. In MongoDB, there is no need to explicitly create a primary key. The NoSQL database offers an _id field, created by default, with every document. This created field acts as a primary key. The reserved _id field serves as the primary key in MongoDB, and it must be of unique value. It is important to note that if there is no set up to the _id field, MongoDB fills it with “MongoDB Id Object” automatically.</li><li><strong>MongoDB Uses CAP Theorem: </strong>RDBMS focuses on ACID properties via Atomicity, Consistency, Isolation, and Durability. On the other hand, MongoDB uses CAP theorem Consistency, Availability, and Partition tolerance for database distributions.</li><li><strong>Ad-hoc Query Support</strong></li><li><strong>Full Technical Support and Documentation</strong></li><li><strong>Powerful Querying and Analytics</strong></li></ul><h3>Disadvantages of Using MongoDB</h3><ul><li><strong>High Memory Usage: </strong>MongoDB stores key names for each value pair. Also, due to the lack of functionality of joins, there is data redundancy. This results in increasing unnecessary usage of memory.</li><li><strong>Limited Data Size: </strong>You can have document size, not more than 16MB.</li><li><strong>Limited Nesting: </strong>You cannot perform nesting of documents for more than 100 levels.</li><li><strong>Not Support Transaction: </strong>One of the downsides of MongoDB is that it doesn’t support transactions. Though fewer and fewer applications are requiring transactions, there are still some that need transactions in order to update multiple documents/collections. If that’s a necessary function for your team, MongoDB should not be used. There’s potential for data corruption.</li><li><strong>Duplicates: </strong>Some of these downsides could ultimately lead to duplicate data (as has happened for many users in the past). The relationships in MongoDB are not typically well-defined and the resulting duplicate data sets can be hard to handle. That, along with not being ACID compliant, would lead to corrupted data as well.</li><li><strong>Indexing: </strong>As mentioned earlier, enjoying MongoDB’s quick speeds and high performance is only possible with the right indexes. With shoddily implemented indexes and out of order composite indexes, MongoDB will operate at a shockingly slow speed.</li><li><strong>Not support join operation</strong></li></ul><h3>Features of MongoDB</h3><ul><li><strong>Ad-hoc Queries for Optimized, Real-Time Analytics: </strong>It is difficult to predict all of the queries that will be run by end-users when creating a database structure. An ad hoc query is a one-time command that depends on the value of a variable. Depending on the variables in question, the outcome of an ad hoc query may alter each time it is run. When hundreds to millions of factors need to be evaluated, optimizing how ad-hoc queries are handled may make a big impact. MongoDB, a document-oriented, flexible schema database, is the cloud database platform of choice for corporate applications that demand real-time analytics for this reason. The performance gained from ad-hoc query functionality, which allows developers to update ad-hoc queries in real-time, can be game-changing. Field queries, range queries, and regular expression searches are all supported by MongoDB. User-defined functions can be accounted for in queries that return specified fields. Because MongoDB indexes BSON documents and employs the MongoDB Query Language (MQL).</li><li><strong>Load Balancing: </strong>At the end of the day, proper load balancing for developing corporate applications remains one of the holy grails of large-scale database administration. A considerable (and much-appreciated) change in performance may be achieved by properly spreading millions of client requests among hundreds or thousands of servers. MongoDB, fortunately, provides large-scale load balancing via horizontal scaling capabilities like replication and Sharding. With best-in-class concurrency management and locking mechanisms that maintain data consistency, the platform can handle several concurrent read and write requests for the same data. There’s no need to employ an external load balancer because MongoDB ensures that every user sees the same data and has a good experience with it.</li><li><strong>Sharding</strong></li><li><strong>Replication for Better Data Availability and Stability</strong></li><li><strong>Indexing appropriately for better query executions</strong></li></ul><h3>Installation</h3><h4>How to Install MongoDB on Windows</h4><h4>Prerequisites</h4><ul><li>The users of Windows must know that their windows desktop has got one of two versions. i.e., 32-bit &amp; 64-bit.</li><li>This information could be found in the properties of one’s “<em>My Computer</em>” or “<em>This PC</em>” on their device i.e., either their windows are 32-bit or 64-bit.</li></ul><p>Download the binaries from the <a href="https://www.mongodb.com/try#production">MongoDB Download Center</a>.</p><ol><li>Open Windows Explorer/File Explorer.</li><li>Change the directory path to where you downloaded the MongoDB <strong>.msi</strong> file. By default, this is <strong>%HOMEPATH%\Downloads</strong>.</li><li>Double-click the <strong>.msi</strong> file.</li><li>The Windows Installer guides you through the installation process.</li><li>If you choose the <strong>Custom</strong> installation option, you may specify an installation directory.</li><li>MongoDB does not have any other system dependencies. You can install and run MongoDB from any folder you choose.</li></ol><p><strong>NOTE:</strong> <br>This tutorial assumes that installed MongoDB in <strong>C:\Program Files\MongoDB\Server\4.2\</strong>.</p><h4>How to RUN MongoDB on Windows</h4><h4>Step 1: Set up the MongoDB Environment</h4><ul><li>MongoDB requires a <a href="https://www.mongodb.com/docs/manual/reference/glossary/#std-term-dbpath">data directory</a> to store all data. MongoDB’s default data directory path is the absolute path <strong>\data\db</strong> on the drive from which you start MongoDB. Create this folder by running the following command in a <strong>Command Prompt</strong>: <strong>md \data\db</strong></li><li>You can specify an alternate path for data files using the <a href="https://www.mongodb.com/docs/manual/reference/program/mongod/#std-option-mongod.--dbpath">— — dbpath</a> option to <a href="https://www.mongodb.com/docs/manual/reference/program/mongod.exe/#mongodb-binary-bin.mongod.exe">mongod.exe</a>, for example: <strong>“C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe” — — dbpath d:\test\mongodb\data</strong></li><li>If your path includes spaces, enclose the entire path in double quotes, for example: <strong>“C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe” — — dbpath “d:\test\mongo db data”</strong></li><li>You may also specify the <strong>dbpath</strong> in a <a href="https://www.mongodb.com/docs/manual/reference/configuration-options/">configuration file</a>.</li></ul><h4>Step 2: Start MongoDB</h4><ul><li>To start MongoDB, run <a href="https://www.mongodb.com/docs/manual/reference/program/mongod.exe/#mongodb-binary-bin.mongod.exe">mongod.exe</a>. For example, from the Command Prompt: <strong>“C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe”</strong></li><li>This starts the main MongoDB database process. The waiting for connections message in the console output indicates that the <a href="https://www.mongodb.com/docs/manual/reference/program/mongod.exe/#mongodb-binary-bin.mongod.exe">mongod.exe</a> process is running successfully.</li><li>Depending on the security level of your system, Windows may pop up a <strong>Security Alert</strong> dialog box about blocking “some features” of <strong>C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe</strong> from communicating on networks. All users should select <strong>Private Netwroks, such as my home or work network</strong>, and click <strong>Allow Access</strong>.</li><li>For additional information on security and MongoDB, please see the <a href="https://www.mongodb.com/docs/manual/security/">Security Documentation</a>.</li></ul><h4>Step 3: Verify that MongoDb has started successfully</h4><ul><li>Verify that MongoDB has started successfully by checking the process output for the following line: <strong>[initandlisten] waiting for connections on port 27017</strong></li><li>The output should be visible in the terminal or shell window.</li><li>You may see non-critical warnings in the process output. As long as you see the log line shown above, you can safely ignore these warnings during your initial evaluation of MongoDB.</li></ul><h4>Step 4: Connect to MongoDB</h4><ul><li>To connect to MongoDB through the <a href="https://www.mongodb.com/docs/404/#mongodb-binary-bin.mongo">~bin.mongo.exe </a>shell, open another <strong>Command Prompt:</strong> <strong>“C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe”</strong></li></ul><p>That concludes part one of this MongoDB tutorial. We’ve looked at MongoDB briefly in this blog. If you want to learn more about MongoDB, visit its <a href="https://www.mongodb.com/">website</a>, find it on <a href="https://github.com/mongodb/mongo">Github</a> or check out this repository of <a href="https://github.com/mongodb/mongo">examples</a>.</p><p>In the next part of this tutorial, we’ll learn more about MongoDB and how to build a CRUD application with MongoDB. Leave a comment below if you have any questions or comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e44bcb4b6194" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NodeJS Tutorial Part One (Introduction)]]></title>
            <link>https://medium.com/@hansakadilshanjayawardana/nodejs-tutorial-part-one-introduction-854f0f30efd7?source=rss-844f07119a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/854f0f30efd7</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hansaka Dilshan Jayawardana]]></dc:creator>
            <pubDate>Tue, 29 Nov 2022 08:10:40 GMT</pubDate>
            <atom:updated>2022-11-29T08:29:33.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HE8e3unhuR66fyG4kTqfzw.jpeg" /></figure><h3>What is NodeJS?</h3><p>NodeJS is a scalable network application builder that uses an asynchronous event-driven JavaScript engine. NodeJS is a free programming language. It is an open-source Chrome’s JavaScript runtime environment, allows you to develop scalable online apps with ease. This environment is built on top of Google Chrome’s JavaScript Engine V8. It uses an event-driven, non-blocking I/O model, which makes it lightweight, efficient, and ideal for data-intensive real-time applications that operate across several devices. NodeJS runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.).</p><p>Before we go any further, there are two things you should be aware of,</p><ul><li>NodeJS is a programming environment, not a programming language or framework.</li><li>Contrary to common belief, NodeJS may be used on both the front and backend of a web application.</li></ul><h3>Benefits of Using NodeJS</h3><ul><li><strong>The ability to scale up quickly: </strong>In NodeJS, each node is based around an “event.” For instance, a customer could make an in-app purchase or send an email to customer service. There’s almost no limit to how many nodes you can add to your basic programming function. This means you may scale vertically by introducing new capability paths back to your application’s core code. You may also scale horizontally by adding new resources into existing code. In either way, scalability allows your application to expand, which is one of the main advantages of using NodeJS.</li><li><strong>Speed and Performance: </strong>The environment’s non-blocking input-output operations make it one of the fastest solutions accessible. Code executes rapidly, which improves the overall run-time environment. This is largely due to its sectioned-off system. But it also has something to do with the Google V8 JavaScript engine. Its programs are more likely to be written in JavaScript from end to end, and the plug-and-play compatibility helps with speed and performance.</li><li><strong>The accessibility of a single programming language: </strong>Programmers may easily tie nodes into the rest of the full-stack development because it is powered by JavaScript. This makes it easier for front-end developers to take on more challenging back-end programming tasks. There are no other server-side languages required. That is a positive thing since it speeds up development in almost every area and allows programmers of all levels easy access to the back end of your mobile apps. It is one of the most important benefits of NodeJS.</li><li><strong>Easy to master: </strong>NodeJS is easy to learn, primarily because it’s based on JavaScript. This makes it easier for your front-end programmers or designers to learn more complicated server-side programming with ease.</li><li><strong>Real-time communication: </strong>It maintains a steady connection between the user and the server, ensuring that there is no lag between what the user requests and the server’s response. While other run-time systems attempt to interpret a message letter by letter, it has already completed the request in its entirety. It is also worth noting that it supports Websockets, one of the most widely used real-time communication solutions in the market. You may ensure that your users are constantly in sync with you by using NodeJS features like this one.</li><li><strong>Cross-platform development</strong></li><li><strong>Robust technology stack</strong></li><li><strong>Fast-processing and event-based model</strong></li><li><strong>Rich ecosystem</strong></li><li><strong>Strong corporate support</strong></li><li><strong>Seamless JSON support</strong></li><li><strong>Flexibility</strong></li><li><strong>Efficient caching</strong></li><li><strong>Fast-to-market-development</strong></li><li><strong>An active user community</strong></li><li><strong>Efficient Queueing of Requests</strong></li><li><strong>A better choice for mobile</strong></li><li><strong>Node Package Manager for Enterprise</strong></li></ul><h3>Disadvantages of Using NodeJS</h3><ul><li><strong>Inability to process CPU bound tasks quickly: </strong>Because it processes JavaScript, which is also single-threaded, it is deemed single-threaded. Its non-blocking input/output approach employs an event loop to asynchronously handle threads. And everything is OK until Node is assigned a CPU-intensive task. It gives priority to these CPU-intensive operations first, resulting in delayed processing and overall latency in the event loop. This is why many programmers believe Node.js is unsuitable for programs that demand a lot of computing. It’s worth noting that as part of the 10.5.0 upgrade in 2018, it added a multi-threading capability called worker threads. This module may make use of extra threads from a thread pool, allowing for the execution of demanding parallel tasks on multiple threads. It’s currently considered experimental, but it might help to mitigate this evident problem in the future. Still, it’s one of Node’s advantages and disadvantages to consider carefully.</li><li><strong>Unstable API: </strong>Its Application User Interface has changed multiple times. Not all of the modifications are compatible with previous versions. That implies developers will have to make changes to the exposed code bases only to be compatible with the current NodeJS API version. It is not always the best situation.</li><li><strong>Callback hell issue: </strong>Because of its asynchronous nature, Node.js mainly relies on callbacks, which are routines that execute whenever each job in the queue has completed. Keep an eye out if you have a lot of queued jobs operating in the background. You might end up in “callback hell,” as Node engineers call it, which has a direct influence on code quality. Callbacks become buried many layers deep as a result of this.</li><li><strong>Hot competition for Node programmers</strong></li><li><strong>A weak library system</strong></li><li><strong>Performance bottlenecks with heavy computation tasks</strong></li><li><strong>Immaturity of tooling</strong></li><li><strong>An overgrown, yet immature npm module registry</strong></li></ul><h3>Features of NodeJS</h3><ul><li><strong>Asynchronous and Event Driven: </strong>The APIs of the NodeJS library are all asynchronous (non-blocking). A server built in NodeJS never has to wait for data from an API. The server moves on to the next API after accessing one. It uses a notification system called Events to receive and track replies to previous API requests.</li><li><strong>Very Fast: </strong>When data is sent in numerous streams, it takes a long time to process them all. NodeJS is a rapid data processing framework. It concurrently processes and uploads a file, which saves a lot of time. As a result, NodeJS boosts data and video streaming performance.</li><li><strong>Single Threaded but Highly Scalable: </strong>NodeJS uses a single threaded model with event looping. In contrast to traditional servers, which create limited threads to handle requests, the event mechanism allows the server to respond in a non-blocking way and makes it highly scalable. When compared to conventional servers like Apache HTTP Server, NodeJS uses a single threaded application that can handle a considerably higher number of requests.</li><li><strong>No Buffering: </strong>Data is never buffered in a NodeJS application. The data is simply output in chunks by these apps.</li><li><strong>Uses JavaScript: </strong>The NodeJS library makes use of JavaScript, which is another key feature of NodeJS from an engineer’s perspective. JavaScript is already familiar to most of the engineers. As a result, working with NodeJS will be lot easier for a designer who is comfortable with JavaScript.</li><li><strong>Cross-platform compatibility: </strong>NodeJS is compatible with a wide range of operating systems, including Windows, Unix, Linux, Mac OS X, and mobile devices. It can be used in conjunction with the proper package to generate a self-sufficient executable.</li><li><strong>License</strong></li></ul><h3>Installation</h3><p><strong>Prerequisites</strong></p><ul><li>A user account with administrator privileges (or the ability to download and install software)</li><li>Access to the windows command line (search &gt; cmd &gt; right-click &gt; run as administrator) OR Windows PowerShell (Search &gt; Powershell &gt; right-click &gt; run as administrator)</li></ul><h3>How to Install NodeJS and NPM on Windows</h3><h4>Step 1: Download Node.js Installer</h4><p>In a web browser, navigate to <a href="https://www.blogger.com/blog/post/edit/1091841715730063333/6183476953942096886?hl=en#">https://nodejs.org/en/download/</a>. To download the latest default version, click the <strong>Windows Installer</strong> button. Version 16.14.0 -x64 was the most recent version at the time this article was published. The NPM package manager is included in the NodeJS installer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*XYFoS6eIhG26y13b4094OQ.png" /></figure><h4>Step 2: Install Node.js and NPM from Browser</h4><ol><li>Once the installer finishes downloading, launch it. Open the <strong>downloads</strong> link in your browser and click the file. Or browse to the location where you have saved the file and double-click it to launch.</li><li>The system will ask if you want to run the software — click <strong>Run</strong>.</li><li>You will be welcomed to the NodeJS Setup Wizard — click <strong>Next</strong>.</li><li>On the next screen, review the license agreement. Click <strong>Next</strong> if you agree to the terms and install the software.</li><li>The installer will prompt you for the installation location. Leave the default location, unless you have a specific need to install it somewhere else — then click <strong>Next</strong>.</li><li>The wizard will let you select components to include or remove from the installation. Again, unless you have a specific need, accept the defaults by clicking <strong>Next</strong>.</li><li>Finally, click the Install button to run the installer. When it finishes, click <strong>Finish</strong>.</li></ol><h4>Step 3: Verify Installation</h4><p>Open a command prompt (or PowerShell), and enter the following:</p><p>node –v</p><p>The system should display the NodeJS version installed on your system. You can do the same for NPM:</p><p>npm –v</p><h3>How to Update Node.js and NPM on Windows</h3><h4>Option 1: Update NodeJS on Windows with Installer</h4><p>One option to update your NodeJS up to date is to go to its official download page and download the latest version. Bz doing so, the system should overwrite the older version with the updated one.</p><ol><li>Navigate to the <a href="https://www.blogger.com/blog/post/edit/1091841715730063333/6183476953942096886?hl=en#">NodeJS website</a> and click on the latest stable version or the newest current release (with the latest features).</li><li>After deciding the version, click on the <strong>Windows</strong>. The system downloads the package and stores it in the specified directory.</li><li>Once the download is complete, run the installer.</li><li>The NodeJS Setup Wizard appears and guides you through the installation.</li><li>Accept the License Agreement by checking the box and click <strong>Next</strong>.</li><li>Choose the destination folder where you want to install NodeJS.</li><li>NodeJS allows you to select how you want to install the Node features. Change the way the features are installed by clicking on the icons in the tree.</li><li>With that, the latest NodeJS is ready to install. Click <strong>Install</strong> to confirm, wait until the installation completes, and click <strong>Finish</strong>.</li><li>Check the NodeJS version with the command:<br>node –v</li></ol><h4>Option 2: Update NodeJS on Windows with NPM</h4><p>If you want to upgrade NodeJS from the command line, use the n model within the npm command. The n feature allows you to interact with different NodeJS versions.</p><ol><li>Before updating the NodeJS release, check which version you are currently using with:<br>node –v</li><li>Next, clear npm cache with the command: <br>npm cache clean –f</li><li>Install n globally:<br>npm install –g n</li><li>Now that you have n installed, you can use the module to install the latest stable release of NodeJS:<br>sudo n stable</li></ol><h3>How to Uninstall NodeJS and NPM on Windows</h3><p>You can uninstall NodeJS from the Control Panel in Windows.</p><p>To do so:</p><ol><li>Click the <strong>Start</strong> button &gt; <strong>Settings</strong> (gear icon) &gt; <strong>Apps</strong>.</li><li>Scroll down to find <strong>Node.js</strong> and click to highlight.</li><li>Select <strong>Uninstall</strong>. This launches a wizard to uninstall the software.</li></ol><p>That concludes part one of this NodeJS tutorial. We’ve looked at NodeJS briefly in this blog. If you want to learn more about NodeJS, visit its <a href="https://nodejs.org/en/">website</a>, find it on <a href="https://github.com/nodejs/node">Github</a> or check out this repository of <a href="https://github.com/nodejs/examples">examples</a>.</p><p>In the next part of this tutorial, we’ll learn more about Node and how to build a CRUD application. Leave a comment below if you have any questions or comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=854f0f30efd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Koa.js Tutorial Part One (Introduction)]]></title>
            <link>https://medium.com/@hansakadilshanjayawardana/koa-js-tutorial-part-one-introduction-d7bde493676b?source=rss-844f07119a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7bde493676b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[koa]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[koajs]]></category>
            <dc:creator><![CDATA[Hansaka Dilshan Jayawardana]]></dc:creator>
            <pubDate>Tue, 29 Nov 2022 07:43:44 GMT</pubDate>
            <atom:updated>2022-11-29T08:15:42.614Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*1zsLXJfA8EAC-WWgG5pchQ.jpeg" /></figure><h3>What is koa.js?</h3><p>Koa.js is a widely used server-side framework for Node.js. Koa was created by the same creators of express, another popular javascript framework. Koa.js is a lightweight framework for developing applications and APIs. Koa.js eliminates callbacks and significantly improves error handling by leveraging async functions. The core of Koa.js does not include any middleware, but it does include an elegant set of methods for writing servers quickly and easily.</p><p>Each request is composed and executed in a stack-like manner by Koa.js, which contains an array of middleware generator functions.</p><h3>Goals of koa.js</h3><p>Aims to be a smaller, more expressive, and more robust foundation for web applications and APIs.</p><h3>Benefits of Using koa.js</h3><ul><li><strong>Extremely Lightweight: </strong>Smaller footprint than any other node.js framework including Express. Thinner and better middleware. You have the option to extend the framework.</li><li><strong>Modern Framework: </strong>Koa is built ES6+ and promotes modern javascript syntax. Uses generators and async / await. Helps developers create apps that remain relevant over a long period of time.</li><li><strong>Request &amp; Response: </strong>Koa.js uses a req and res object on top of the standard vanilla javascript request and response. It accelerates HTTP server development by providing additional functionality. Encapsulates req / res into a single object using context. This helps developers build APIs more efficiently by using a number of helpful methods.</li><li><strong>Has a very good user experience</strong></li><li><strong>Better error handling through try / catch</strong></li><li><strong>Generated-based control flow</strong></li><li><strong>No more callbacks, facilitating an upstream and downstream flow of control</strong></li><li><strong>Koa improves interoperability, robustness, and makes writing middleware much more enjoyable</strong></li><li><strong>Simple to learn if you know Express</strong></li></ul><h3>Disadvantages of Using koa.js</h3><ul><li><strong>The open-source community is modest in comparison to other communities</strong></li><li><strong>Express-style middleware is incompatible</strong></li><li><strong>Koa employs generators that are incompatible with the rest of the Nodejs framework’s middleware</strong></li></ul><h3>Features of koa.js</h3><ul><li><strong>Modern and Futuristic: </strong>It was built using the ES6 specifications. ES6 makes it easier to develop any sophisticated program by having many new classes and modules. As a result, it aids developers in the development of maintainable applications that remain valid over time.</li><li><strong>Minimal Footprint: </strong>Koa.js has a smaller footprint than other node.js frameworks. This helps developers to create middleware that is thinner and more efficient. They do, however, have the option of plugging in many modules to expand the system to meet the needs of various projects.</li><li><strong>Use of ES6 Generators: </strong>It is used to ease synchronous programming and to facilitate control flow both upstream and downstream.</li><li><strong>Improved Error Handling: </strong>Koa.js simplifies and improves error handling by making better use of middleware. The framework’s built-in error catchall helps developers avoid website crashes. Programmers may report errors with a simple ‘try/catch’ command without writing any additional code. Developers can also configure error handling in koa.js by simply modifying the default setting.</li></ul><h3>Common koa.js Addon Modules</h3><ul><li><strong>Koa Router: </strong>Koa.js does not code with a built-in router as it is very minimalistic. Koa-router is a simple routing module.</li><li><strong>Koa EJS Templating: </strong>Easy to use template engine to display views &amp; layout. Of course, you can use a frontend framework as well.</li><li><strong>Koa Body Parser: </strong>Pase incoming data</li></ul><h3>Performance</h3><p>You can create high-performance web apps with koa.js. This is due to the fact that you can eliminate callbacks, deal with errors faster, and koa is a very lightweight framework. Furthermore, it simplifies the code management procedure.</p><p>It is important to consider the best practices for having a better performance in node.js like running things in parallel, using asynchronous APIs in your code, keeping code small and light, and using gzip compression.</p><p>The performance request per second for a basic “Hello World” program is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*S6C6fRdTRCs04dln" /></figure><h3>Installation</h3><p>Koa requires node v7.6.0 or higher for ES2015 and async function support. You can quickly install a supported version of node with your favorite version manager:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/0*hPEXlQ91jK1UszuU" /></figure><h3>How is koa.js different from express.js?</h3><p>Using promises and async features, Koa eliminates callback hell and simplifies error handling. It exposes its own ctx.request and ctx.response objects instead of the node’s req and res objects.</p><p>Express, on the other hand, adds additional properties and methods to the req and res objects in node, as well as many other framework features like routing and templating that Koa lacks.</p><p>Other differences are:</p><ul><li>No callback hell</li><li>Absence of boilerplate codes</li><li>Enhanced user experience in general</li><li>Using try/catch, you can better handle errors</li><li>Koa.js is less dependent on middleware</li><li>Koa.js is more modular</li><li>In contrast to Express, routing is not provided</li><li>Proper Stream handling</li></ul><p>That concludes part one of this koa.js tutorial. We’ve looked at Koa.js briefly in this blog. If you want to learn more about Koa.js, visit its <a href="https://koajs.com/">website</a>, find it on <a href="https://github.com/koajs/koa">Github</a> or, check out this repository of <a href="https://github.com/JscramblerBlog/examples">examples</a>. A <a href="https://github.com/koajs/koa/blob/master/docs/guide.md">guide</a>, <a href="https://github.com/koajs/koa/blob/master/docs/faq.md">FAQ</a>, and, <a href="https://github.com/koajs/koa/wiki">wiki</a> are also available.</p><p>In the next part of this tutorial, we’ll learn more about Koa and how to build a CRUD application. Leave a comment below if you have any questions or comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7bde493676b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>