Category: Node.js – Restful with Express framework + MySQL

Installation of Node.js (Windows) No ratings yet.

Before working on the examples, let’s setup the environment first: Install MySQL (using 5.7 for our example), you can download from Download and install Node.js version 4.X from Run “cmd”, and using it to install necessary modules Install Express framework by “npm install express” Install ejs template engine by “npm install ejs” Install logger Morgan by “npm install morgan”

Example 1: Simple Web Page with MySQL connection No ratings yet.

This example will show you how to connect to MySQL database and response output to webpage. Please download the schema.sql here, and run it with MySQL client. /* create database */ CREATE DATABASE itblogs DEFAULT CHARACTER SET utf8;   USE itblogs;   CREATE TABLE COMPANY( id BIGINT NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT NULL, background 

Example 2: MVC App No ratings yet.

Like other famous development languages, such as .NET and Java, node.js does have development framework like MVC. This example will show you how to buildup a small MVC web application using express framework. Please note that this example is based on express version 4.13.4 . Let’s create the folders: example under {your_node.js_installed_path}\nodejs\ demo2 under {your_node.js_installed_path}\nodejs\examples\

Example 3: Restful API Running with AngularJS Web CRUD UI No ratings yet.

You can download the Web UI here, extract the zip file as folder “AngularUI”. As we will run the Node.js Restful API with port 3000, and Web UI using Tomcat with port 8080. Assuming you have installed Tomcat. Otherwise, please download and install Tomcat from . Then, store the unzip package “AngularUI” under {your_tomcat_installed_path}\webapps\

Example 4: Audio and Video Streaming App No ratings yet.

This example will show you how to stream audio and video using Node.js , you will find that it is so simple to do so with just a few line of codes. Let’s try create a new app with some folders: example under {your_node.js_installed_path}\nodejs\ demo4 under {your_node.js_installed_path}\nodejs\examples\ files under {your_node.js_installed_path}\nodejs\examples\demo4\files\ log under {your_node.js_installed_path}\nodejs\examples\demo4\log\   Folder

Example 5: Socket IO App No ratings yet.

This example will show you how to create a socket IO server and client using Node.js , it will demonstrate how to setup a socket IO server, and how to send socket message to server. Let’s try creating below folders: example under {your_node.js_installed_path}\nodejs\ demo5 under {your_node.js_installed_path}\nodejs\examples\   Then, create below 2 js files under {your_node.js_installed_path}\nodejs\examples\demo5\