<?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 Saranya Mohandas on Medium]]></title>
        <description><![CDATA[Stories by Saranya Mohandas on Medium]]></description>
        <link>https://medium.com/@saranyamohandas2?source=rss-695cfa4da48d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cuH_ne_3xjHotd0M</url>
            <title>Stories by Saranya Mohandas on Medium</title>
            <link>https://medium.com/@saranyamohandas2?source=rss-695cfa4da48d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:12:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saranyamohandas2/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[Journey with REACT]]></title>
            <link>https://medium.com/@saranyamohandas2/journey-with-react-c377a5b78b66?source=rss-695cfa4da48d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c377a5b78b66</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Saranya Mohandas]]></dc:creator>
            <pubDate>Mon, 11 Feb 2019 07:10:01 GMT</pubDate>
            <atom:updated>2019-02-11T07:10:01.041Z</atom:updated>
            <content:encoded><![CDATA[<p>As a web developer, we come across lot of libraries and frameworks. We are in a position to choose the best framework or library for our project. How do we make a decision? Should we go for popular one’s or for the one’s that is actually helpful for our project? Why REACT? When I first started learning REACT, I was kind of started losing my confidence on learning it. I really had hard time trying to understand and process it’s concept. I was not even confident when I first used REACT in my project.</p><p>One concept of REACT that interested me was was component reusability. I have developed full stack projects in past but learning REACT was much more challenging than what I learnt so far. I have developed Apps in Angular and I thought that was most challenging framework to learn until I learnt REACT. If you are beginner to REACT and intimidated at first, I would say you are not alone. We have all come across that path.</p><p>When learning new frameworks, as a web developer we should be able to adapt to it’s logic rather than what we learnt in previous frameworks. It is best to have a clear mind to learn new framework so it helps to adapt easily. Comparing and reasoning in between learning will be a step back in learning.</p><p>I had so many questions and made comparison between frameworks and libraries I learnt in past. This made everything difficult for me and I ended up complicating things. Then, I relaxed and realized that I should think in REACT way. This made me to understand things clearly than before. If you are new to REACT or any frameworks take some time to process it’s logic than the usual way. This doesn’t make things easy but gives you some clarity. They all use basics of HTML/CSS/Javascript and built it their own way. So understanding that basic is important. For instance, REACT has stateless and stateful components. Having some clarity on understanding where and why to use it will be a stepping stone. One of the best REACT tutorial I came across was by Mosh Hamedani <a href="https://youtu.be/Ke90Tje7VS0">https://youtu.be/Ke90Tje7VS0</a></p><p>Good luck with your stateful journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c377a5b78b66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passportjs with Mysql sequelize and expressjs]]></title>
            <link>https://medium.com/@saranyamohandas2/passportjs-with-mysql-sequelize-and-expressjs-56fb903aaf8f?source=rss-695cfa4da48d------2</link>
            <guid isPermaLink="false">https://medium.com/p/56fb903aaf8f</guid>
            <category><![CDATA[passportjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Saranya Mohandas]]></dc:creator>
            <pubDate>Fri, 18 Jan 2019 06:15:42 GMT</pubDate>
            <atom:updated>2019-01-18T06:15:42.906Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Passportjs with Mysql sequelize and expressjs</em></strong></p><p>Well, it is time for another blog. This time I want to write on a feature I implemented for our project.</p><p>I was looking for authentication feature for our project. I came across passportjs. I tried to understand passportjs but I felt their documents were not much detailed. So I went thru few blogs and refined the best one to understand its functionality and here is my experience on implementing in my project.</p><p>Passportjs is a middleware for nodejs and it is compatible with expressjs.</p><p>Passportjs in turn uses bcrypt middleware module for password encryption.</p><p>Passportjs has built in methods called Strategies that helps users to implement their choice on authentication like google signin/signup,Facebook signin/signup,Twitter signin/signup etc.. We can use the strategy that is essential for our application. I am using local signin/signup strategy for this application.</p><p>Logic here is pretty straight forward. Any application that needs to authenticate user will have to use signin/signup feature.</p><ol><li>Strategy -we will use local signin/signup strategy in our application. When a user enters correct email and password combination, the application gives user to access the application. We cannot save email and password as such in database which would compromise the user data. Here’s where passport comes in action.</li><li>Serialize/Deserialize -Good web application needs to maintain persistent user login throughout the usage for better user experience. When a user is authenticated to his profile, there are couple of actions he would perform which is expected . User does some sort of action in front-end and subsequent request is made to server. Back-end listens to the request and performs certain operation and returns response to user if any. These back-end operations include CRUD operations to database or could be any algorithm. When such operations are done in back-end,user could get sign out of his current session. App can handle request but it cannot handle the session persistence by default. In order to provide persistent login session experience to user,we need to serialize user to session with some kind of id or data. It’s like making the server remember the user with some hint in this case it’s going to be id. Serialize extracts id and deserialize checks for the id.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*rHedvVZlP-CRo4GyleXLmg.png" /><figcaption>Authentication flow chart</figcaption></figure><p>Setting up View — We will create a simple signin and signup handlerbars</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01ea8b42127caccf8d920aad77ba6adb/href">https://medium.com/media/01ea8b42127caccf8d920aad77ba6adb/href</a></iframe><p>Setting up controller and model -</p><p>First we will create a .env file and set up app. Follow the below steps -</p><ol><li>create a file and add NODE_ENV=’development’. Save it as as .env.</li></ol><p>2. npm install all the dependencies given in the require method as mentioned in the below code. We will walk thru each line of code one by one -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3f1c9546a68eb6c65d5e7dc98964a98/href">https://medium.com/media/f3f1c9546a68eb6c65d5e7dc98964a98/href</a></iframe><p>3. Create a js file and copy the above code and save it as server.js. This file is going to establish connection to port and keep the server running.</p><p>4. Checklist for installing dependencies— express,dotenv,body-parser,passport,handlebars,mysql,bcrypt,sequelize.</p><p>5. Below code initializes passport and connects app to middleware. Passport uses it built in sessions and strategies for authentication and persisting sessions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2528846e04cdf96e0f76258f2b98cdc/href">https://medium.com/media/f2528846e04cdf96e0f76258f2b98cdc/href</a></iframe><p>Model -</p><ol><li>We have to create models in order to create tables. Create a folder name in models and create two files inside it. Save one of the file as index.js and other as auth.js.</li><li>Index file is specific for sequelize . Sequelize looks for index.js in models folder in order to create instance of the models from models directory. Sequelize will sync the models with the database and afterwards start the server.</li></ol><p>Below code is nothing customized for this app. It is available in sequelize documentation as well. Copy the below code to index.js -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bdd42ba574cf62a05313012cedb3d37/href">https://medium.com/media/3bdd42ba574cf62a05313012cedb3d37/href</a></iframe><p>3. Define model for Authentication table. We will save it as auth.js and define the following columns in the table -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/123d72b528675ae6672f5a1c0e5a2378/href">https://medium.com/media/123d72b528675ae6672f5a1c0e5a2378/href</a></iframe><p>4. We need a model to create tables and establish connection with database. Since we are using sequelize, we need to set up some config files for that. Create a folder named config and create config.json and add the below code required for db connection.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65f2b5f835987c3887b0bdd014fc6404/href">https://medium.com/media/65f2b5f835987c3887b0bdd014fc6404/href</a></iframe><p>5. Make sure to replace your credentials for mysql username,password,database and host in development . Do not worry about the rest of the part.</p><p>6. In config folder,create another folder named passport and inside the folder create a file name passport.js. Copy paste the below code -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13a50993f281b909bf71b15805daf6ab/href">https://medium.com/media/13a50993f281b909bf71b15805daf6ab/href</a></iframe><p>Code walk thru -</p><p>Line 2–3 - we define the dependencies.</p><p>Line 8 - we create a function that is exported to server.js in order to insert/read/update from database.</p><p>Line 11- since we are using passport local signup/signin, we include passport local strategy.</p><p>Line 13 -when a new user signup with email id and password, app uses bcrypt module for encrypting the password. This function queries database for checking if the email id is linked with any existing users. If the email is available already, function throws error. If the email doesn’t exist in database, the application authorizes user into respective page.</p><p>Line 60 -Like wise, for signin, the function checks whether the email id and password combination is valid and authorizes user into the application.</p><p>Line 128–151 -these methods takes care of serializing and deserializing user with the session. Please refer to top of page on what does serialization and deserialization means.</p><p>Routes -We have set up routes for our application to render appropriate page.</p><ol><li>Create a folder named routes. Inside the same folder,create a file and save it as auth-route.js. Copy paste the below code -</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/137f4bfacecd234b6d11f49bd277fb46/href">https://medium.com/media/137f4bfacecd234b6d11f49bd277fb46/href</a></iframe><p>Below is the folder structure for reference -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*BSVbv9GtYavmChFM49MF3g.png" /><figcaption>Folder structure</figcaption></figure><p>So, we are set and app is ready to run. Run server.js from command line and open your localhost. You should be able to signin and signup. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56fb903aaf8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event delegation in JavaScript/JQuery]]></title>
            <link>https://medium.com/@saranyamohandas2/event-delegation-in-javascript-jquery-aa788019fcf9?source=rss-695cfa4da48d------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa788019fcf9</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jquery]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Saranya Mohandas]]></dc:creator>
            <pubDate>Thu, 06 Dec 2018 06:56:41 GMT</pubDate>
            <atom:updated>2018-12-06T06:56:41.068Z</atom:updated>
            <content:encoded><![CDATA[<h4>A beginner’s blog on web development –</h4><p>Event delegation: I will keep it simple for you. So here we are in my blog and I know most of us just wanted the solution at this point of time and no blah blah…</p><p>We will get into the problem right away ! Okay, I did a great job adding elements dynamically to DOM. Now I wanted to add event listener to dynamically added elements and I did it in right way as but events are not added and I am wondering why!!!</p><p>Whether using plain/vanilla javascript or jquery, does adding events to dynamically generated elements work? No!! they don’t ! In javascript, you can add events to DOM elements that exist at the time of load but not for dynamically generated elements.</p><p>Below is the code where I have dynamically created child elements &lt;li&gt; to Parent &lt;ul&gt;. Even after adding click event to child element, click event is not triggered. This is because events can be added only to elements that are available in DOM at the time of initial load. To handle this, any event has to be added to parent and then that event is delegated from Parent to child. It might seem tricky initially but think it as feeding an expectant mom you feed a baby that hasn’t seen the world yet! That’s how it works!!</p><p>This is called event delegation in Javascript and it is one of the basic and important concept that every Web/UI developer has to come across at some point of time in his/her web development journey.</p><p>Below is the example where unordered list is generated dynamically. I have added “click” event and upon clicking a particular child, color of the respective element should change to red. But the code does not work as expected.</p><p>Below is the example when event is added directly to child element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4eed06353ea3ddbb4bc779418bb49cb/href">https://medium.com/media/b4eed06353ea3ddbb4bc779418bb49cb/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa4bba6d5a3fa283510a87388e12ee0e/href">https://medium.com/media/aa4bba6d5a3fa283510a87388e12ee0e/href</a></iframe><p>Below is the resolved code where event is added to parent &lt;ul&gt; and then delegated to child &lt;li&gt;. Make sure to add &lt;li&gt; child element inside click function. This ensures event to be added to each child element and color of child element is changed only when particular child is clicked. If &lt;li&gt; is not added to click function, clicking on one child changes color of all child.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/195b077849dee5f9e2cf4af3e33a74c0/href">https://medium.com/media/195b077849dee5f9e2cf4af3e33a74c0/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Frcyou%2Fembed%2Fpreview%2FQEObEk%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DQEObEk&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Frcyou%2Fpen%2FQEObEk%2F&amp;image=https%3A%2F%2Fassets.codepen.io%2F113804%2Finternal%2Fscreenshots%2Fpens%2FQEObEk.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dfalse%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1468346461%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/67a858d441399bd1870370cd3686dd3d/href">https://medium.com/media/67a858d441399bd1870370cd3686dd3d/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fsaranyamohandas%2Fembed%2Fpreview%2FaQgQMY%3Fheight%3D600%26slug-hash%3DaQgQMY%26default-tabs%3Djs%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fsaranyamohandas%2Fpen%2FaQgQMY%3Feditors%3D1111&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F2397107.aQgQMY.small.4ff29484-3000-4cce-93f4-dd8a5ce4108f.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/41fcc186024b344d3ad7263de261082a/href">https://medium.com/media/41fcc186024b344d3ad7263de261082a/href</a></iframe><h4><em>Some thoughts for beginners in web development -</em></h4><p>How to handle the pressure of updating yourself with rapidly growing technology!!</p><p>I am experienced SDET and interested in web technology. I decided to learn web technology. I started off learning basics of web technology through some good websites like w3schools and online tutorials. Basics went well and I was excited to learn more. But getting further on road I found myself lost sometimes. I get stuck and I sit hours on issues sometimes lame and sometimes challenging. Don’t doubt yourself it is how it is and you are not alone. It is not a smooth road and never give up.</p><p>Is it possible to attain mastery in Technology!! May be!! May be not!! You can never attain mastery of technology even If you are the one who developed frameworks/introduced a new language. Technology keeps evolving day by day. One day we feel master and other day we don’t. Every new development is intimidating at some point.</p><p>One thing I realized was there is no saturation point to technology. How to handle this? Try to be proficient in what you do. You don’t have to be proficient in every innovation. Tech industry is constantly evolving and scrapping yesterday’s knowledge. So, try to understand the scope of your project and not worry on updating every new development .</p><p>As a beginner in web development we might be frustrated sometimes keeping up with new updates. Just think at what point of time you are going to use it and then learn it. If you don’t get solution to your issues, google it. Most solutions are available on good forums like Stack overflow,css tricks etc.. Hacker rank is one of the sites I find most helpful to enhance my logical and problem solving skills -<a href="https://www.hackerrank.com/">https://www.hackerrank.com/</a>.</p><p>More frustrations are on the way to come..Keep fingers crossed!!</p><p><em>If you find my blog useful, please give me a thumbs up!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa788019fcf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>