How to Connect to MySQL Database from a Web-based Application in Node.js

This is an article where the main subject is actually about how to connet to MySQL Database from a web-based application which runs in NodeJS. The main base of the web-based application project will use the one generated in the article titled ‘How to Create an Express Web-based Framework Application to be deployed in Node.js’ in this link.

So, the following is steps taken in order for the application can connect to MySQL Database.

Continue reading

How to Install Express MyConnection Package or Module for Web-based Application powered by Express Framework in Node.js

This is an article where the main content is about how to install Express MyConnection package or module. It is a package or module which is added for special reason. The main reason is for the express framework powering a web-based application have the ability to connect to MySQL Database. Based on the description given in this link where the actual blog of the person created it. Based on the explanation on the person created which is written on the blog of the person himself, he mentioned that he had alreadly created the super simple middleware module express-myconnection that provides a consistent API for MySQL connections during the request/response life cycle. It is also stated that it supports three different strategies of managing db connections: single for a singleton connection on an app instance level, pool based connections, and a new connection per each request. Another feature described is that it is also capable of auto releasing/closing connections if configured with either theĀ pool or request strategy. But aside of that, the installation process itself is actually quite simple when it is actually involving npm tool. The process taken is shown as follows :

Continue reading

How to Install MySQL Database Package or Module for Web-based Application powered by Express Framework in Node.js

This article is an article where the title itself is quite a long title. But the main subject is focusing on how to install MySQL Database package or module. The package or module itself is used by the web-based application powered by the express framework. It can be referred from the article titled ‘How to Create an Express Web-based Framework Application to be deployed in Node.js’ in this link. So, the following are steps taken in order for the MySQL Database package or module to be installed in the web-based application :

Continue reading

How to Make a Hello World Application in NodeJS

This article is written to show a specific purpose which is to show how to make a string “Hello World!”, normally a word which is usually taken to test a simple output can be presented in any normal programming language used. In the context of this article, it is using a Javascript which is executed in NodeJS as a tools which is taking a role as a Server-side Javascript render processing entity. The steps are simple where the base folder for this purpose can be taken from the one generated using express framework. The reference for generating a folder that is actually a web-based application powered by express framework can be taken from the article titled ‘How to Create an Express Web-based Framework Application to be deployed in Node.js’ in this link. Below are steps taken after having the folder mentioned before generated :

Continue reading

How to Display Simple Default Page of a Web Page powered by Express Framework in Node.js

The main goal is stated in the title of the article. It is done after creating a web-based application using express framework as shown in the article titled ‘How to Check to Package Dependencies in Web-based Application powered by Express Framework using npm’ in this link. The folder which contains files needed for a simple default page can be presented or can be displayed in a web browser is already created. So, the remaining things to be done is adding line for the app can be presented or can be displayed in a web browser. The steps taken to accomplish the task is shown as follows :

1. Add the following line into the file named app.js :

app.listen(3000);

The line of script means that the application executed will start listen in port 3000. So, if there is any request further directed to that port, the application will serve and response the request.

2. Just start the application by using the command tool ‘node’. Below is the actual pattern of the command tool execution :

node javascript_file

Below is the actual execution of the above command. And for an example, the javascript_file which is mentioned in the command pattern above will be using the default file generated. That file’s name is ‘app.js’, so the execution file is shown as follows :

user@hostname:~/nodejs/test$ node app.js 
GET / 200 676ms - 170b
GET /stylesheets/style.css 200 17ms - 110b

So, by executing the above command, node is actually serving itself to listen in to the port specified in the app.js file which is in the port 3000. So, every request send directly to port 3000 will be served by node and the response will be given back. The following is the output of the request made in the web browser :

How to Display Simple Default Page of a Web Page powered by Express Framework in Node.js

How to Display Simple Default Page of a Web Page powered by Express Framework in Node.js

As shown in the above output, there is something printed in the page which is indicating the web-page powered by Express framework.