<?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 Brendan Tran on Medium]]></title>
        <description><![CDATA[Stories by Brendan Tran on Medium]]></description>
        <link>https://medium.com/@btran418?source=rss-7a4d54b63150------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*H0zddGTVkDmdVeKC.jpg</url>
            <title>Stories by Brendan Tran on Medium</title>
            <link>https://medium.com/@btran418?source=rss-7a4d54b63150------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 11:16:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@btran418/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[Starting a Log-in System with NodeJS]]></title>
            <link>https://medium.com/@btran418/starting-a-log-in-system-with-nodejs-7ab0dfac47a1?source=rss-7a4d54b63150------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ab0dfac47a1</guid>
            <dc:creator><![CDATA[Brendan Tran]]></dc:creator>
            <pubDate>Mon, 06 Apr 2020 01:10:11 GMT</pubDate>
            <atom:updated>2020-04-06T01:10:11.548Z</atom:updated>
            <content:encoded><![CDATA[<p>Previously we have built a simple web server and even one where we serve NodeJS server some html, here we continue to build upon what we have learned and pick up something new. If you want to see what we learned about before give a quick read <a href="https://medium.com/@btran418/setting-up-a-website-with-nodejs-e98d19c908dc"><em>here</em>.</a> During the past three months I have been fiddling around and learning about NodeJS and its functional capabilities and its ability to work along with other modules to build web applications.</p><p>In this blog I will be going through some basic steps and installing MongoDB, talk a briefly about Express middleware, and how we’re going to setup to help point you in the right direction to start your own log-in system for members to enjoy your growing web application.</p><h4>Installing and Setting up our Database</h4><p>For our application we will use MangoDB since it integrates well with NodeJS and we also have Mongoos a NodeJS module we are going to use to help us send and retrieve information from our MangoDB. Lets start by heading to <a href="https://www.mongodb.com/download-center/community?tck=docs_server"><em>MongoDB download center</em></a> in order to do a <strong>complete</strong> install and set up MangoDB.</p><p>With MongoDB installed we will be able to create collections and save data from customers who make accounts for our web applications. MongoDB also has an terminal interface that will allow us to create and check our database information.</p><p>Once you’ve downloaded the program, we can open our command prompt by typing “<strong>cmd</strong>” in the start search bar and use the terminal to navigate to the bin folder in order start creating out first database collection for our Log-in System. Here in the bin folder you can type in “<strong>mongo</strong>” in order to start the interface for MongoDB. Should look something like this image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*un-Bi6B7Wjl4WWEvzGfgdw.png" /></figure><p>You can see that you are now using the MongoDB interface with the little “&gt;” allowing you to type in commands to fetch your database collection and information. Now we can start by creating a new database collection by entering <strong>db.createCollection(‘collection_name’).</strong> We should check which database we are in by typing <strong>db</strong>, switch database with<strong> use db_name </strong>and also<strong> </strong>we can check what databases we currenttly have with<strong> show dbs</strong>.</p><p>Let’s go over some other basic as well, like inserting, updating, removing and view information from the database which you can see in the images i’ve used down below with four different commands all used with <strong>db.db_name.function_call()</strong>. You can see that the<strong> </strong>three function are<strong> insert(), update(), remove() and find()</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*f_0p-IZmlssVgr-zyC12fA.png" /><figcaption>Insert information to Database</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*VK_Vq2zxOteBrzowj5-9Wg.png" /><figcaption>Update your database information</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*Q-WlqRNxfiXy9hrx6pJmTw.png" /><figcaption>Remove from database collection</figcaption></figure><p>Now that we have created our base database we can now exit the command prompt and continue as we did before in my last blogs and create a dependency pack with our needed modules.</p><h4>Middleware and App Set-up</h4><p>In our project, we will need some code called middleware, but what is that exactly? Well a quick way to explain it would be that, it’s a function that NodeJS uses with its modules in order for the modules to handle and manipulate request and response objects. If you’d like to read more up on this topic and understand a bit more about what the middleware is for check out this blog on <a href="https://medium.com/@selvaganesh93/how-node-js-middleware-works-d8e02a936113"><em>How Node JS middleware Works</em></a><em>?. </em>For the middleware we will be using will be for Express, one specifically i’ll be using will be expressValidator which will help validate our form information and make sure our guest server request are valid. We can find it by simply doing a search for expressValidator middleware on google we can copy the code straight into our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*S0W2Mn3K9a6FYkVLTDE0UA.png" /><figcaption>Express-Validator Middleware from Github</figcaption></figure><h4>Registration Form with MongoDB and NodeJS</h4><p>With your middleware set and ready, we’ll need to write some code for our database in order to save information filled out by customers in our website forms. MongoDB being already installed and setup, we will use the mongoos to connect and be passed data from our web forms being filled and submitted. We will export this code snippet and use it to insert the new create account information after we validate that it has been properly filled out. You can see how i’ve set up my connection and validate my code before creating a new user below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*gGTqNRfrQAt11hyiUJ2EcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*ttE9ok86ZUbK6quN2esipQ.png" /><figcaption>Using Mongoos to connect to MongoDB and pass data</figcaption></figure><p>In the image in the left you can see how I have exported the code in order for me to be able to call the variable <strong>User</strong> and the function <strong>createUser() </strong>in the right image around the bottom of the code. Importing the code allowed me to use the checkBody() function in order to validate the entered data before using the imported code to seamlessly create a new account for the guest by passing in the validated information.</p><h3>Conclusion</h3><p>I hope with my brief explanation about middleware, and a quick tutorial on how to use and set up MongoDB with NodeJS. Now you’ll be able to create a simple web application where your guest can create an account and enjoy more of your beautiful content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ab0dfac47a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up a Website with NodeJS]]></title>
            <link>https://medium.com/@btran418/setting-up-a-website-with-nodejs-e98d19c908dc?source=rss-7a4d54b63150------2</link>
            <guid isPermaLink="false">https://medium.com/p/e98d19c908dc</guid>
            <category><![CDATA[node-js-tutorial]]></category>
            <dc:creator><![CDATA[Brendan Tran]]></dc:creator>
            <pubDate>Mon, 24 Feb 2020 04:59:18 GMT</pubDate>
            <atom:updated>2020-02-24T05:09:22.345Z</atom:updated>
            <content:encoded><![CDATA[<p>Keeping the theme of my last post, I’ll be going in a more in depth explanation in setting up a simple server that can be served HTML files in order to create a very simple web server. We’ll start with a simple visit to NodeJS website to take a look at the typical programmer start to any new technology, the “Hello World” example.</p><h3>Super Simple Hello World Web Server</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*tVtOOAo_0_18d4kPiLe52w.png" /><figcaption><a href="https://nodejs.org/en/about/">https://nodejs.org/en/about/</a></figcaption></figure><p>Using NodeJS example we can see that in the first line we have used the built in <strong>http</strong> module in order answer to http <strong>request</strong> and <strong>response. </strong>Following that we can see that we have set a <strong>host name</strong> to our local host <strong>127.0.0.1</strong> and a <strong>port </strong>number of<strong> 3000</strong>. Now that we have that we can now create a function called <strong>server</strong> that will handle the <strong>req</strong>uest and <strong>res</strong>ponse when a client connects to the host and port. Now when we run this snippet of code we will get a console log of where the server is running and have a simple web server such that when a client connects to they should see “Hello World”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*gAENqTzZKz6-02E3C2Q9hQ.png" /></figure><p>With the use of Git Command Line GUI, you can easily navigate in your project folders and open Git to run the code. Using Git, you can start your server by entering <strong>npm start</strong> or <strong>node</strong> followed by the <strong>file name</strong>. You can see how I start and run my NodeJS server below. A quick note on stopping your server with <strong>ctl+c </strong>key command in the Git window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*syG12Z6in2bWxh2mBuAbhA.png" /><figcaption>Node Start</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*xCtRZYbNiXbcfIeDO8v8Ng.png" /><figcaption>Node Server.js</figcaption></figure><h3>Simple Web Server served with HTML, CSS and JS</h3><p>Now that we have seen a basic web server using NodeJS, I’ll show you how you can set one up with your own html, css and javascript files being served as the website content. Just like the first example we will need to declare some modules that we will need in order to get the proper files and let the server know what we will be sending it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*hT3iaizCdYUgqQgvuAFNnw.png" /></figure><p>In this snippet of code we can see that we will be using the http, url, path and fs modules. With these modules we will be able to handle http request and responses, serve a url, get a file paths and our actual file names that will be served to the server when a client connects to the server. Along with these modules that are built into NodeJS, we will have also declared the file types that will be used and served to the server.</p><p>Now to set up the server actions and what happens when a client connects to the server and what they will see when they do or can’t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*3rLnDEbGk2-nWiOc-1G1kw.png" /><figcaption>Server Request and Response</figcaption></figure><p>Here you can see that we will handle three cases when a client connects to the server. We will still run this on our local host and still have it listen to request on port 3000, which is designated for running NodeJS.</p><p>In our first case starting at line 28 in a try catch block, we will check if the files being served to the client is valid and presentable. Along with that we will respond with a <strong>404 status code </strong>if the file was invalid, but if it is we will then move to line 38. The start of this if statement will check if the information being accessed is either a file or directory. If the infomation being served is a file, the server will respond with the a <strong>status code 200</strong>, meaning that the <strong>file and server connection is okay</strong> and be is able to serve the client the requested file. In the case the server finds that request is actually a directory it will instead respond withe a <strong>status code of</strong> <strong>302</strong>, meaning <strong>directory found </strong>and will serve the file in the specified<strong> {‘Location’ : ‘index.html’}. </strong>In this example I have used past html, css and javascript projects to serve as my test code and it turned out great, a simple drag drop into my project folder and it simple worked when started the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fsj7Hj_Zdp9HloluP9TCHg.png" /><figcaption>Metric Converter</figcaption></figure><p>There are two super simple example in order to set up a basic web server using NodeJS. With that you’ve only scratch the surface with the power and flexibility of NodeJS as a web server, with that in mind I hope you give it a whirl and create your own basic site using NodeJS in your backend server development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e98d19c908dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Starting Out With Node.js]]></title>
            <link>https://medium.com/@btran418/starting-out-with-node-js-c95b86e867b3?source=rss-7a4d54b63150------2</link>
            <guid isPermaLink="false">https://medium.com/p/c95b86e867b3</guid>
            <dc:creator><![CDATA[Brendan Tran]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 07:21:33 GMT</pubDate>
            <atom:updated>2020-01-27T07:21:33.003Z</atom:updated>
            <content:encoded><![CDATA[<p>Being a current second year student at a post secondary technical school, I have been given the chance to be taught some front end development skills such as some coding with JavaScript to develop a front end working website. With my current skills still growing and improving, I sought to explore and research some currently used technologies that I could learn using my current skills knowledge. With JavaScript in mind and a peaked interest in full stack development I found myself learning more about Node.js. In this blog I’ll briefly be talking about information to where as you can get Node.js, the reason why I chose Node.js, how does Node.js work and who is using currently using Node.js.</p><h3>Where Can I Get Node.js?</h3><p>Allowing their technology to be an open source forum ran by a community committee of developers who have helped Node.js’ current and constant updates and developments. This also allows developers such as myself to access their technology through their website. By going to their website <a href="https://nodejs.org/en/">https://nodejs.org/en/</a> or doing a simple google search on Node.js in your web browser you’ll be able to get started by downloading Node.js either their Long Term Support (LTS) or their current working version.</p><h3>So Why Node.js?</h3><p>Node.js is a fast JavaScript runtime engine that was modeled after Google’s V8 Engine that runs on your chrome web browser. The difference between the two technologies is that Node.js allows developers to run JavaScript on their computers and not be used for just client side development but also server side as well. This allows developers to access and run JavaScript files right on their computer and as well allow them to monitor and listen to traffic on their network. Since Node.js uses JavaScript as its primary coding language makes it easy for developers to use it both on the front and back when developing their project. Compared to other technologies, Node.js is an asynchronous event driven making it faster when it comes to non processing requests such as sending and receive information over a chat or retrieving data from your server.</p><h3>How Does Node.js Work?</h3><p>Being an asynchronous event driven means that as a request comes through the network, Node.js will push events and request onto a stack and deal with them as they come in. If there is an even that needs to come around finish then an event callback in the program called an event-loop will push any missed or timed events onto the stack and finish the current request. We will learn more about this as I dive deeper into the of Node.js.</p><p>“ In the following “hello world” example, many connections can be handled concurrently. Upon each connection, the callback is fired, but if there is no work to be done, Node.js will sleep.”</p><p><a href="https://nodejs.org/en/about/">https://nodejs.org/en/about/</a></p><h3>Who is Current Using Node.js</h3><p>In our vast technical world and our streaming on demand sites many companies such as Netflix, Walmart, Uber and even Paypal use Node.js as their server side technology in order to help their user access their massive amount of data and quickly navigate around their site to enjoy your favorite content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c95b86e867b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>