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\
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
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 http://tomcat.apache.org/download-80.cgi . Then, store the unzip package “AngularUI” under {your_tomcat_installed_path}\webapps\
This example will show you how to create a Node.js Restful API for the backend, and it will be called by the frontend – AngularJS. The Node.js Restful API will response with JSON output to AngularJS frontend. You will find that it is so simple to do so. You will find that the folder structure
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\
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
Throughout our examples, some required npm packages need to be installed, some of them can be installed by npm – build-in package management tool, and the remaining are bundled with Node.js . Please find the below packages and their details: Package Express NPM Install npm install express Functions Provide the coding framework Usage Create the
Before working on the examples, let’s setup the environment first: Install MySQL (using 5.7 for our example), you can download from http://dev.mysql.com/downloads/mysql/ Download and install Node.js version 4.X from https://nodejs.org/en/ 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”
Why use Node.js? You may hear people saying that node.js is not good, poor performance, and not for enterprise application. Before answering this question, we better to have a look to the below pros and cons. Then, we can conclude what kind of application is good to build with node.js, and what is not.