skip to main content
Skip header Section
Beginning Node.jsNovember 2014
Publisher:
  • Apress
  • 901 Grayson Street Suite 204 Berkely, CA
  • United States
ISBN:978-1-4842-0188-6
Published:28 November 2014
Pages:
308
Skip Bibliometrics Section
Bibliometrics
Skip Abstract Section
Abstract

Beginning Node.js is your step-by-step guide to learning all the aspects of creating maintainable Node.js applications. You will see how Node.js is focused on creating high-performing, highly-scalable websites, and how easy it is to get started. Many front-end devs regularly work with HTML, CSS, PHP, even WordPress, but haven't yet got started with Node.js. This book explains everything for you from a beginner level, enabling you to start using Node.js in your projects right away. Using this book you will learn important Node.js concepts for server-side programming. You will begin with an easy-to-follow pure JavaScript primer, which you can skip if you're confident of your JS skills. You'll then delve into Node.js concepts such as streams and events, and the technology involved in building full-stack Node.js applications. You'll also learn how to test your Node.js code, and deploy your Node.js applications on the internet. Node.js is a great and simple platform to work with. It is lightweight, easy to deploy and manage. You will see how using Node.js can be a fun and rewarding experience - start today with Beginning Node.js. What youll learn Learn how JavaScript can help you be highly productive as a full-stack developer How to set up an end to end Node.js development environment Learn how to create reusable and maintainable Node.js modules Patterns for sharing code between the server and the client Create Node.js restful web services and websites Store and retrieve your data using Document Databases How to test your Node.js applications How to deploy your applications on the internet Who this book is for Beginning Node.js is great for front-end developers looking to use Node.js in their websites. If you understand the basics of programming this book will teach you how you can leverage JavaScript to create full stack web-apps using Node.js. Node.js allows you to write code that runs both on the client and server. This allows you to reuse more code and deliver applications faster. From this book you will learn how to write maintainable server-side JavaScript using Node.js, how to test your code and deploy it on the internet.

Contributors

Recommendations

Adrian Pasculescu

Software developers or computer-savvy people who need an excellent introduction to this relatively recent alternative to well-established web servers and web server coding are the audience for this book. It is well written and logical, with gradually increasing complexity and many downloadable and easy examples. All chapters have a short introduction and end with a summary and sometimes additional resources. Chapter 1, "Setting Up for Node.js Development," describes Node.js installation on Apple Mac or Microsoft platforms. Computer screen shots accelerate learning and are used throughout the book. Here, any reader armed with a computer and downloaded examples can trigger the first "Hello World" app. Next, "Understanding Node.js" introduces the basic elements of JavaScript and follows with descriptions of objects, error handling, and basic object-oriented programming (OOP). Readers will understand the concept of a web server in different implementations and how Node.js is different: an event loop in one JavaScript thread. Possible drawbacks such as thread starvation are mentioned here, too. The focus of chapter 3, "Core Node.js," is importing and exporting data/objects and sharing in-memory objects. Readers will learn about conditional loading of modules and how execution is blocked until the code is loaded (very important in an asynchronous environment). Some core modules and "globals" are introduced: path, fs, os, util, console, setTimeout, setInterval, clearInterval, and so on, with excellent notes about differences between synchronous and asynchronous execution. In chapter 4, "Node.js Packages," the main topics gravitate around the Node.js package manager (npm). It emphasizes module side effects and incompatibility. It introduces the JavaScript object notation (JSON) format, its utility functions, and semantic version numbering. It exemplifies functional programming through popular packages such as underscore (for basic data processing), optimist (for handling command line arguments), moment (for date formatting), colors, and others. In my opinion, "Events and Streams" (chapter 5) is essential for understanding OOP implementation in JavaScript. Inheritance can be defined by "__proto__" chains and ".call" or simplified via "inherit" from the "util" package. Other topics touched on here include events, subscribing and unsubscribing listeners, sharing between subscribers, possible memory leaks, errors, signals and exception handling, and the pipes and streams. Key to building web-based applications is chapter 6: "Getting Started with HTTP." The author reveals the anatomy of the hypertext transfer protocol (HTTP) request and response, the raw communication streams between server and client, and shows how packages like "connect" can simplify coding. He gradually introduces authorization, authentication, and the need for encryption, with many hints on good coding practices. "Introducing Express," chapter 7, describes a package providing a standard optimized and well-tested web application framework with many out-of-the-box functionalities: serve static pages, serveindex, JSON requests parsing, embedded URLencode, and so on. The author exemplifies representational state transfer (REST) methods for data collection management and webpage routing. Chapter 8, "Persisting Data," focuses on nonrelational databases that help with the management of collections of documents, data trees, or graphs. Unfortunately, the example source code is damaged and could not be used. Understandably, specialized solutions like MongoDB can simplify development. The next chapter, "Front-End Basics," clearly explains the concept of a single-page application and how XMLHttpRequest is used to render changes in the already present webpage. The examples use the angular framework, the popular bootstrap.css, and jQuery library. The code is more complex and many coding conventions are mentioned. With so many chained callback functions in the Node.js asynchronous environment, chapter 10, "Simplifying Callbacks," becomes very important. The order of execution can be controlled by the use of process.nextTick and the modern and popular "promises" (asynchronous code constructs placed in a queue after the execution of the synchronous code). Other concepts described here are generators with or without promises. Chapter 11, "Debugging," presents functions such as console.log, console.time, console.timeEnd, console.trace, and console.error, and debugging options (setting breakpoints, watch variables, step-by-step execution) or additional tools and utilities such as node-inspector and Webstorm. As a logical continuation, in "Testing" (chapter 12) we see popular constructs such as assert, which is important for verifying code conformity to requirements. Testing frameworks such as mocha, chai, or node-inspector can further ease testing and allow stopping and resuming execution at will for detailed debugging. The book ends with "Deployment and Scalability," which exemplifies automatic node restarting and communication between child workers using fork and process. It finishes with a description of Amazon Web Services and shows a quick installation and deployment of a small Node.js-based web application. The examples for chapter 13 are missing in the zipped downloadable code. It's up to the reader to decide whether using JavaScript on the browser as well as the web server (Node.js) is a good thing, as the author argues at the start. More reviews about this item: Amazon , Goodreads Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.