Node.JS Guidebook
eBook - ePub

Node.JS Guidebook

Comprehensive guide to learn Node.js

Dhruti Shah

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Node.JS Guidebook

Comprehensive guide to learn Node.js

Dhruti Shah

Book details
Book preview
Table of contents
Citations

About This Book

Develop attractive and efficient dynamic web applications using Node.js Key Features

  • Assumes a practical approach of learning.
  • Ample of examples are given along with assignments.
  • Book covers a wide range of topics in Node.js, emphasising on real-world.
  • Simple language is used with clear presentation of topics including Node.js modules, npm, event handling.


Description
The Node.js Guidebook is written and designed keeping in mind readers of varies technical and academic inclinations. Every concept has been explained in detail with appropriate examples and demonstrations with images as applicable. Topics have been aligned from simple to complex for the benefit of a beginner in understanding the technology. The logic of all codes in the examples have been explained appropriately. Concepts have been described in a simple language for easy understanding along with real-world applications of the same.Node.js Guidebook aims to introduce readers to the world of Node.js. Node.js is an open source JavaScript run-time environment that executes JavaScript on server-side. Earlier, JavaScript was used only for client-side scripting, but Node.js supports the creation of dynamic Web applications by using JavaScript for server-side scripting. Node.js has taken the world by a storm by simplifying Web application development thorough the use of readily available and pluggable modules, thus, reducing the overall development time. Whether you are a beginner or an experienced developer, you can learn to design and develop attractive and efficient Web applications using Node.js. What Will You Learn
This book will help developers to easily develop attractive and efficient dynamic web applications using Node.js. It will be a great source of reference for developers for migrating applications to open source technologies such as HTML5, Node.js, and MySQL. Who This Book Is For
This book will prove to be a "must have" for beginners as well as experienced professionals as it is a stepping stone for learning new technology. Table of Contents
1. Introduction to Node.js
2. Modules in Node.js
3. File system module
4. NPM in node.js
5. Event handling in Node.js
6. Node.js with MySQL
7. Express and Node.js About the Author
Dhruti Shah is a multi-skilled, tech savvy person with more than 12 years of experience as a software trainer, technical writer, project lead and manager in the field of education and training in Information Technology. She holds a Master of Computer Applications (MCA) degree from South Gujarat University. She is a Microsoft Certified Training Specialist and has trained more than 2000 candidates world-wide on more than 10 technologies. With a keen sense of technological advancement, she has self-acquired working knowledge of several technologies including Java, .NET, PHP, Linux, SQL Server, MySQL, Node.js and so on. She has authored books on these technologies for educational institutions and also conducted webinars on technical subjects for international clients like Nigeria, Vietnam, and Trinidad. She has been appreciated as a model representative for India for flawlessly managing two prestigious International projects to set up and upgrade the Centre of Excellence in Information Technology in Panama and Costa Rica, Central America (a collaboration project of Indian government with the governments of Panama and Costa Rica).

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Node.JS Guidebook an online PDF/ePUB?
Yes, you can access Node.JS Guidebook by Dhruti Shah in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in JavaScript. We have over one million books available in our catalogue for you to explore.

Information

SECTION 1

■ ■ ■

Introduction to Node.js

Session Objectives

  • Understand the concept behind Node.js.
  • Understand the features of Node.js.
  • Learn to work with Node.js REPL terminal.
  • Learn to use Node.js with Command Line Interface.
  • Learn to use Node.js with an Integrated Development Environment (IDE).
  • Compare Node.js with other JavaScript based technologies.

1.1 Introduction

Node.js is an open-source framework based on JavaScript. It was developed by Ryan Dahl in 2009. It is designed from the JavaScript V8 Engine of Google Chrome. Node.js was released under the MIT Licence. It is freely available and its codes are written in JavaScript that work on several platforms such as Windows, Mac OS X, Linux, etc.
[Note: Massachusetts Institute of Technology (MIT) License is a permissive free software license. It puts very limited restrictions on reuse and also provides better license compatibility.]
Normally, JavaScript only runs in the browser but cannot run on the machine. Node.js allows the JavaScript to run on the machine. This allows access to the file system and listen to network traffic on the machine. Also, it can handle HTTP requests like a Web server and send back responses including files. It can directly access databases from JavaScript. In short, anything which can be done with PHP or ASP can now be done by using JavaScript. That is, Node.js uses JavaScript on the server.

1.1.1 Features and Benefits of Node.js

  1. It provides a cross-platform runtime environment as well as a JavaScript library.
  2. It is lightweight and very useful for data-intensive applications that work real-time and across several devices. This is because, Node.js uses an event-driven, single-threaded, non-blocking I/O model which is very memory efficient.
  3. It uses asynchronous programming methodology in which the server does not have to wait for the first request to complete in order to handle another request.
  4. Node.js library executes the code very quickly as it is built on the V8 JavaScript Engine of Google Chrome
  5. Unlike other servers, Node.js does not support buffering of data. The data is displayed in chunks.
  6. Node.js can read, write, create, open and close files on a server.
  7. It can also create, add, update, and delete data from databases.
  8. Node.js can generate dynamic page content and collect form data from a Web page
  9. Node.js uses a single-thread model with event looping so that the applications work in a non-blocking manner and become highly scalable. Due to event-looping mechanism, a single thread can handle more number of requests as compared to existing servers such as HTTP server, Apache server, etc.
[Note: Scalability of an application is measured on the basis of the number of user requests a server can handle. Highly scalable application means it can handle lot of user requests at a time]
Following figure depicts some important parts of Node.js:
Figure 1.1: Parts of Node.js

1.1.2 Types of Applications that can be Developed Using Node.js

Node.js can be used to develop a variety of applications including:
  • Web and networking applications.
  • Video streaming sites which are I/O intensive Web applications.
  • Single-page applications.
  • Data Intensive Real-time Applications (DIRT).
  • JSON APIs based Applications.

1.1.3 Asynchronous Programming with Node.js

Normally, when a request is sent to a Web server for fetching data or files, technologies such as PHP or ASP would handle it by sending the request to the server. However, until the server does not open, read and return the data or file content to the client, it cannot handle another request. Only after the first request is completed, the next request is addressed.
However, Node.js follows the asynchronous methodology. Here, the request is sent to the server or the computer’s file system first. While the server opens, reads and returns the data to the client, at the same time the next request is handled by Node.js. In short, the waiting time is eliminated and the application can serve multiple requests at a time.

1.2 Set up the Node.js Environment

For using Node.js, download and install the latest version of Node.js from the official page https://nodejs.org
To install Node.js, double-click the Windows Installer MSI file and follow the instructions of...

Table of contents