Introduction

Welcome to Node.js, MongoDB and Angular Web Development. This book is designed to catapult you into the world of using JavaScript—from the server and services to the browser client—in your web development projects. The book covers the implementation and integration of Node.js, MongoDB, and Angular—some of the most exciting and innovative technologies emerging in the world of web development.

This introduction covers

Images Who should read this book

Images Why you should read this book

Images What you will be able to achieve using this book

Images What Node.js, MongoDB, and Angular are and why they are great technologies

Images How this book is organized

Images Where to find the code examples

Let’s get started.

Who Should Read This Book

This book is aimed at readers who already have an understanding of the basics of HTML and have done some programming in a modern programming language. Having an understanding of JavaScript will make this book easier to digest but is not required because the book does cover the basics of JavaScript.

Why You Should Read This Book

This book will teach you how to create powerful, interactive websites and web applications—from the webserver and services on the server to the browser-based interactive web applications. The technologies covered here are all open source, and you will be able to use JavaScript for both the server-side and browser-side components.

Typical readers of this book want to master Node.js and MongoDB for the purpose of building highly scalable and high-performing websites. Typical readers also want to leverage the MVC/MVVM (Model-View-Controller/Model-View-View-Model) approach of Angular to implement well-designed and structured webpages and web applications. Overall, Node.js, MongoDB, and Angular provide an easy-to-implement, fully integrated web development stack that allows you to implement amazing web applications.

What You Will Learn from This Book

Reading this book will enable you to build real-world, dynamic websites and web applications. Websites no longer consist of simple static content in HTML pages with integrated images and formatted text. Instead, websites have become much more dynamic, with a single page often serving as an entire site or application.

Using Angular technology allows you to build into your webpage logic that can communicate back to the Node.js server and obtain necessary data from the MongoDB database. The combination of Node.js, MongoDB, and Angular allows you to implement interactive, dynamic webpages. The following are just a few of the things that you will learn while reading this book:

Images How to implement a highly scalable and dynamic webserver, using Node.js and Express

Images How to build server-side web services in JavaScript

Images How to implement a MongoDB data store for you web applications

Images How to access and interact with MongoDB from Node.js JavaScript code

Images How to define static and dynamic web routes and implement server-side scripts to support them

Images How to define your own custom Angular components that extend the HTML language

Images How to implement client-side services that can interact with the Node.js webserver

Images How to build dynamic browser views that provide rich user interaction

Images How to add nested components to your webpages

Images How to implement Angular routing to manage navigation between client application views

What Is Node.js?

Node.js, sometimes referred to as just Node, is a development framework that is based on Google’s V8 JavaScript engine. You write Node.js code in JavaScript, and then V8 compiles it into machine code to be executed. You can write most—or maybe even all—of your server-side code in Node.js, including the webserver and the server-side scripts and any supporting web application functionality. The fact that the webserver and the supporting web application scripts are running together in the same server-side application allows for much tighter integration between the webserver and the scripts.

The following are just a few reasons Node.js is a great framework:

Images JavaScript end-to-end: One of the biggest advantages of Node.js is that it allows you to write both server- and client-side scripts in JavaScript. There have always been difficulties in deciding whether to put logic in client-side scripts or server-side scripts. With Node.js you can take JavaScript written on the client and easily adapt it for the server, and vice versa. An added plus is that client developers and server developers are speaking the same language.

Images Event-driven scalability: Node.js applies a unique logic to handling web requests. Rather than having multiple threads waiting to process web requests, with Node.js they are processed on the same thread, using a basic event model. This allows Node.js webservers to scale in ways that traditional webservers can’t.

Images Extensibility: Node.js has a great following and an active development community. People are providing new modules to extend Node.js functionality all the time. Also, it is simple to install and include new modules in Node.js; you can extend a Node.js project to include new functionality in minutes.

Images Fast implementation: Setting up Node.js and developing in it are super easy. In only a few minutes you can install Node.js and have a working webserver.

What Is MongoDB?

MongoDB is an agile and scalable NoSQL database. The name Mongo comes from the word “humongous,” emphasizing the scalability and performance MongoDB provides. MongoDB provides great website backend storage for high-traffic websites that need to store data such as user comments, blogs, or other items because it is quickly scalable and easy to implement.

The following are some of the reasons that MongoDB really fits well in the Node.js stack:

Images Document orientation: Because MongoDB is document-oriented, data is stored in the database in a format that is very close to what you deal with in both server-side and client-side scripts. This eliminates the need to transfer data from rows to objects and back.

Images High performance: MongoDB is one of the highest-performing databases available. Especially today, with more and more people interacting with websites, it is important to have a backend that can support heavy traffic.

Images High availability: MongoDB’s replication model makes it easy to maintain scalability while keeping high performance.

Images High scalability: MongoDB’s structure makes it easy to scale horizontally by sharing the data across multiple servers.

Images No SQL injection: MongoDB is not susceptible to SQL injection (that is, putting SQL statements in web forms or other input from the browser and thereby compromising database security). This is the case because objects are stored as objects, not using SQL strings.

What Is Angular?

Angular is a client-side JavaScript framework developed by Google. The theory behind Angular is to provide a framework that makes it easy to implement well-designed and structured webpages and applications, using an MVC/MVVM framework.

Angular provides functionality to handle user input in the browser, manipulate data on the client side, and control how elements are displayed in the browser view. Here are some of the benefits Angular provides:

Images Data binding: Angular has a clean method for binding data to HTML elements, using its powerful scope mechanism.

Images Extensibility: The Angular architecture allows you to easily extend almost every aspect of the language to provide your own custom implementations.

Images Clean: Angular forces you to write clean, logical code.

Images Reusable code: The combination of extensibility and clean code makes it easy to write reusable code in Angular. In fact, the language often forces you to do so when creating custom services.

Images Support: Google is investing a lot into this project, which gives it an advantage over similar initiatives that have failed.

Images Compatibility: Angular is based on JavaScript and has a close relationship with the JavaScript standard. This makes it easier to begin integrating Angular into your environment and reuse pieces of your existing code within the structure of the Angular framework.

How This Book Is Organized

This book is divided into six main parts:

Images Part I, “Getting Started,” provides an overview of the interaction between Node.js, MongoDB, and Angular and how these three products form a complete web development stack. Chapter 2 is a JavaScript primer that provides the basics of the JavaScript language that you need when implementing Node.js and Angular code.

Images Part II, “Learning Node.js,” covers the Node.js language platform, from installation to implementation of Node.js modules. This part gives you the basic framework you need to implement your own custom Node.js modules as well as the webserver and server-side scripts.

Images Part III, “Learning MongoDB,” covers the MongoDB database, from installation to integration with Node.js applications. This part discusses how to plan your data model to fit your application needs and how to access and interact with MongoDB from your Node.js applications.

Images Part IV, “Using Express to Make Life Easier,” discusses the Express module for Node.js and how to leverage it as the webserver for your application. You learn how to set up dynamic and static routes to data as well as how to implement security, caching, and other webserver basics.

Images Part V, “Learning Angular,” covers the Angular framework architecture and how to integrate it into your Node.js stack. This part covers creating custom HTML components and client-side services that can be leveraged in the browser.

Images Part VI, “Advanced Angular,” covers more advanced Angular development, such as building custom directives and custom services. You also learn about using Angular’s built-in HTTP and routing services. This section finishes with some additional rich UI examples, such as building drag-and-drop components and implementing animations.

Getting the Code Examples

Throughout this book, you will find code examples in listings. The title for each listing includes a filename for the source code. The source code is available for download at the book’s website.

A Final Word

We hope you enjoy learning about Node.js, MongoDB, and Angular as much as we have. They are great, innovative technologies that are fun to use. Soon, you’ll be able to join the many other web developers who use the Node.js-to-Angular web stack to build interactive websites and web applications. Enjoy the book!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.172.38