Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Web Development with MongoDB and NodeJS Second edition
Web Development with MongoDB and NodeJS Second edition

Web Development with MongoDB and NodeJS Second edition: Build an interactive and full-featured web application from scratch using Node.js and MongoDB , Second Edition

Arrow left icon
Profile Icon Satheesh Profile Icon Jason Krol Profile Icon Joseph D'mello
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3 (6 Ratings)
Paperback Oct 2015 300 pages 2nd Edition
eBook
₱579.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial
Arrow left icon
Profile Icon Satheesh Profile Icon Jason Krol Profile Icon Joseph D'mello
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3 (6 Ratings)
Paperback Oct 2015 300 pages 2nd Edition
eBook
₱579.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial
eBook
₱579.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Web Development with MongoDB and NodeJS Second edition

Chapter 1. Welcome to JavaScript in the Full Stack

What an exciting time to be a JavaScript developer! What was once only considered a language to add enhancements and widgets to a web page has since evolved into its own fully-fledged ecosystem. As of the beginning of 2015, it stands as the second most popular language in terms of questions tagged on stack overflow, next to only Java, with around a million questions tagged on it. There are tons of frameworks and environments to make it possible to run JavaScript almost anywhere. I believe Atwood's law says it best:

"Anything that can be written in JavaScript will eventually be written in JavaScript!"

While this quote dates back to 2007, it's never been more true than today. Not only can you use JavaScript to develop a complete single-page application such as Gmail, but you will also see how we can achieve the following projects with JavaScript in the coming chapters of the book:

  • Completely power the backend using Node.js and Express.js
  • Persist data with a powerful document oriented database such as MongoDB
  • Write dynamic HTML pages using Handlebars.js
  • Deploy your entire project to the cloud using services such as Heroku and Amazon Web Services (AWS)

With the introduction of Node.js, JavaScript has officially gone in a direction that was never even possible before. Now you can use JavaScript on the server and you can also use it to develop full-scale, enterprise-level applications. When you combine this with the power of MongoDB and its JSON-powered data, you can work with JavaScript in every layer of your application.

Let's quickly go through some basic concepts of Node.js and MongoDB, which would be helpful for you to follow the rest of the chapters in this book.

A short introduction to Node.js

One of the most important things that people get confused about while getting introduced to Node.js is to understand what exactly it is. Is it a different language altogether, is it just a framework on top of it, or is it something else? Node.js is definitely not a new language, and it is not just a framework on JavaScript. It can be considered as a runtime environment for JavaScript built on top of Google's V8 engine. So, it provides us with a context where we can write JavaScript code on any platform where Node.js can be installed. Anywhere!

Now a bit about its history! Back in 2009, Ryan Dahl gave a presentation at JSConf that changed JavaScript forever. During his presentation, he introduced Node.js to the JavaScript community. After a roughly 45-minute talk, he concluded it, receiving a standing ovation from the audience in the process. He was inspired to write Node.js after he saw a simple file upload progress bar on Flickr, the image-sharing site. Realizing that the site was going about the whole process the wrong way, he decided that there had to be a better solution.

Now let's go through the features of Node.js, which makes it unique from other server-side programming languages.

The advantage that the V8 engine brings in

The V8 engine was developed by Google and was open sourced in 2008. As we all know, JavaScript is an interpreted language and it will not be as efficient as a compiled language, as each line of code gets interpreted one by one while the code gets executed. The V8 engine brings in an efficient model here, where the JavaScript code will be compiled into machine-level code and the executions will happen on the compiled code instead of interpreting the JavaScript. But even though Node.js is using the V8 engine, Joyent, which is the company that is maintaining Node.js development, it does not always update the V8 engine to the latest versions that Google actively releases. This has led to the new branch named io.js, which we will discuss later in this chapter.

Node.js is single threaded!

You might be asking, how does a single threaded model help? Typical PHP, ASP.NET, Ruby, or Java-based servers follow a model where each client request results in the instantiation of a new thread or even a process. When it comes to Node.js, requests are run on the same thread with even shared resources. A common question that is often asked is what will be the advantage of using such a model? To understand this, we should understand the problem that Node.js tries to resolve. It tries to do asynchronous processing on a single thread to provide more performance and scalability for applications that are supposed to handle too much web traffic. Imagine web applications that handle millions of concurrent requests; if the server makes a new thread for handling each request that comes in, it will consume a lot of resources and we would end up trying to add more and more servers to increase the scalability of the application. The single threaded asynchronous processing model has its advantage in the previous context, and you can process much more concurrent requests with less number of server-side resources. However, there is a downside to this approach; Node (by default) will not utilize the number of CPU cores available on the server it is running on without using extra modules like pm2.

Note

The point that Node.js is single threaded doesn't mean that it doesn't use threads internally. It is just that the developer and the execution context that the code has exposure to have no control over the threading model internally used by Node.js.

If you are new to the concept of threads and process, we would suggest you to go through some preliminary articles about these topics. There are plenty of YouTube videos as well on the same topic. The following reference could be used as a starting point:

http://www.cs.ucsb.edu/~rich/class/cs170/notes/IntroThreads/

Non-blocking asynchronous execution

One of the most powerful features of Node is that it is event-driven and asynchronous. So how does an asynchronous model work? Imagine you have a block of code and at some nth line you have an operation that is time consuming. So what happens to the lines that follow the nth line while this code gets executed? In normal synchronous programming models, the lines that follow the nth line will have to wait till the operation at that line completes. An asynchronous model handles this case differently. To handle this scenario in an asynchronous approach, we need to segment the code that follows the nth line into two sections. The first section is dependent on the result of the operation at the nth line and the second section is independent of the result.

We wrap the dependent code in a function with the result of the operation as its parameter, and register it as a callback to the operation on its success. Once the operation completes, the callback function will be triggered with its result. Meanwhile, we can continue executing the result-independent lines without waiting for the result. In this scenario, the execution is never blocked for a process to complete. It just goes on with callback functions registered on each ones completion. Simply put, you assign a callback function to an operation, and when Node determines that the completion event has been fired, it will execute your callback function at that moment.

We can look at an example to understand the asynchronous nature in detail:

console.log('One');
console.log('Two');
setTimeout(function() {
   console.log('Three');
}, 2000);
console.log('Four');
console.log('Five');

In a typical synchronous programming language, executing the preceding code will yield the following output:

One
Two
... (2 second delay) ...
Three
Four
Five

However, in an asynchronous approach, the following output is seen:

One
Two
Four
Five
... (approx. 2 second delay) ...
Three

The function that actually logs Three is known as a callback to the setTimeout function.

Note

If you are still interested in learning more about asynchronous models and the callback concept in JavaScript, Mozilla Developer Network (MDN) has many articles that explain these concepts in detail.

npm – the Node Package Manager

Writing applications with Node is really enjoyable when you realize the sheer wealth of information and tools at your disposal! Using Node's built-in package manager npm, you can find literally tens of thousands of modules that can be installed and used within your application with just a few keystrokes! One of the reasons for the biggest success of Node.js is npm, which is one of the best package managers out there with a very minute learning curve. If this is the first ever package manager that you are getting exposed to, then you should consider yourself lucky!

On a regular month, npm handles more than a billion downloads and it has around 150,000 packages currently available for you to download. You can view the library of available modules by visiting www.npmjs.com. Downloading and installing any module within your application is as simple as executing the npm install package command. Have you written a module that you want to share with the world? You can package it up using npm and upload it to the public www.npmjs.org registry just as easily! If you are not sure how a module you installed works, the source code is right there in your projects' node_modules/ folder waiting to be explored!!

Note

Package versions of modules in npm follow semantic versioning, such as major.minor.patch order.

Sharing and reusing JavaScript

While you develop web applications, you will always end up doing the validations for your UI both at the client and server sides, as the client-side validations are required for better UI experience and server-side validations are needed for better security of app. Think about two different languages in action: you will have the same logic implemented in both the server and client side. With Node.js, you can think of sharing the common function between server and client, reducing the code duplication to a large extent.

Ever worked on optimizing the load time for client-side components of your Single-Page Application (SPA) loaded from template engines such as underscore? You would end up thinking about a way we could share the rendering of templates in both server and client at the same time—some call it hybrid templating. Node.js resolves the context of duplication of client templates better than any other server-side technologies, just because we can use the same JS templating framework and the templates both at server and client.

If you are taking this point lightly, the problem it resolves is not just the issue of reusing validations or templates on the server and client. Think about an SPA being built; you will need to implement the subsets of server-side models in the client-side MV* framework also. Now, think about the templates, models, and controller subsets being shared on both client and server. We are solving a higher scenario of code redundancy.

Not just for building web servers!

Node.js is not just to write JavaScript in the server-side. Yes, we have discussed this point earlier. Node.js sets up the environment for the JavaScript code to work anywhere it can be installed. It can be a powerful solution to create command-line tools as well as fully-featured, locally run applications that have nothing to do with the Web or a browser. Grunt.js is a great example of a Node-powered command-line tool that many web developers use daily to automate everyday tasks such as build processes, compiling CoffeeScript, launching Node servers, running tests, and more.

In addition to command-line tools, Node is increasingly popular among the hardware crowd with the Node bots movement. Johnny-Five and Cylon.js are two popular Node libraries that exist to provide a framework to work with robotics. Just search on YouTube for Node robots and you will see a lot of examples. Also, there is a chance that you might be using a text editor developed on Node.js. GitHub's open source editor named Atom, which is hugely popular, is an example.

Real-time web application with Socket.io

One of the important reasons behind the origin of Node.js was to support real-time web applications. Node.js has a couple of frameworks built for real-time web applications, which are hugely popular: Socket.io and sock.js. These frameworks make it very simple to build instant collaboration-based applications such as Google Drive and Mozilla's together.js. Before the introduction of WebSockets in the modern browsers, this was achieved via long polling, which was not a great solution for real-time experience. While WebSockets is a feature that is only supported in modern browsers, Socket.io acts as a framework, which also features seamless fallback implementations for legacy browsers.

Note

If you need to understand more on the use of WebSockets in applications, here's a good resource on MDN that you can explore:

https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications

Networking and file IO

In addition to the powerful non-blocking asynchronous nature of Node, it also has very robust networking and filesystem tools available via its core modules. With Node's networking modules, you can create server and client applications that accept network connections and communicate via streams and pipes.

The origin of io.js

As we mentioned earlier in this chapter, io.js is nothing but a fork of Node.js created to be updated with the latest development on both V8 and other developments in the JS community. Joyent was taking care of the releases in Node.js and the process that was followed in taking care of the release management of Node.js lacked an open governance model. It leads to scenarios where the newer developments in V8 as well as the JS community were not incorporated into its releases. For example, if you want to write JavaScript using the latest EcmaScript6 (ES6) features, you will have to run it in the harmony mode. Joyent is surely not to be blamed for this, as they were more concerned about stability of Node.js releases than frequent updates in the stack. This led to the io.js fork, which is kept up to date with the latest JavaScript and V8 updates. So, it's better to keep your eyes on the releases on both Node and io.js to be up to date with the Node.js world.

A simple server with Node.js

To see an example of just how lightweight Node can be, let's take a look at some sample code that starts up an HTTP server and sends Hello World to a browser:

var http = require('http');
http.createServer(function (req, res) {
 res.writeHead(200, {'Content-Type': 'text/plain'});
 res.end('Hello World\n');
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080');

A few basic lines of code are all it takes to write a complete Node application. Running it with a simple Node app.js command will launch an HTTP server that is listening on port 8080. Point any browser to http://localhost:8080, and you will see the simple output Hello World on your screen! While this sample app doesn't actually do anything useful, it should give you a glimpse of the kind of power you will have while writing web applications using Node.js. If you don't have the initial Node.js development environment set up, we will discuss it in the next chapter.

When to use Node.js?

You should have heard of this proverb:

"If all you have is a hammer, everything looks like a nail!"

This makes a lot of sense in this context. Node.js is not a technology to depend on all the application problems that you intend to solve and if not chosen wisely, the decision will backfire. Node.js is well suited for applications that are expected to handle a huge amount of concurrent connections. Also, it should be noted that it is most suited for applications where each incoming request requires very few CPU cycles. This means that if you intend to do computation-intensive tasks on requests, it will end up blocking the event loop—thereby impacting other requests concurrently processed by the web server. Node.js is well suited for real-time web applications, such as chat rooms, collaboration tools, online games, and so on. So when deciding whether to use or not use Node.js, we should analyze the application context seriously and figure out whether Node.js really suits the context of the application.

Note

It is quite hard to debate over the use cases of Node.js in a detailed manner. However, the following stackoverflow thread does this so effectively and we strongly recommend you to go though the answers on this post if you are more interested in the use cases of Node.js: http://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-node-js

As we have briefly gone through the features and concept of Node.js, now let's look into the NoSQL and MongoDB side.

The NoSQL movement

Let's start by exploring the answers to the question, what exactly is a NoSQL database? NoSQL is a common term for database technologies that deviate from the traditional Relational Database Management System (RDBMS) concepts. The common reason for these database solutions to deviate from RDBMS database standards is to achieve and set a better standard of availability and partitioning capabilities than traditional RDBMS solutions.

To introduce you to this concept, we should have a look at the Brewer's theorem, which is otherwise known as the CAP theorem:

"It is impossible for a distributed computer system to simultaneously provide all three of the following guarantees: Consistency, Availability, and Partition tolerance."

Traditional RDBMS solutions are good at consistency and compromise a little once it comes to providing better availability (data reads) and partitioning capabilities. Most of the NoSQL solutions have been evolved in this direction to achieve better heights in data availability and partitioning.

As this is a common term for any database technology that deviates from the concepts followed by RDBMS solutions such as MySQL, PostgreSQL, and so on, there are various subsets for NoSQL databases. Most popular subsets of NoSQL are document stores, key-value stores, and graph-based database solutions. MongoDB, which is the one we are going to try out, falls in the document store category. There are many more NoSQL solutions available in the market apart from MongoDB, such as Cassandra, Redis, Neo4j, Hbase, and so on.

A short introduction to MongoDB

As we discussed in the previous paragraph, MongoDB falls into the document store category of NoSQL databases. MongoDB is being actively developed by 10gen, which was later renamed to MongoDB I.inc. MongoDB is open source and its source is available on various platforms such as GitHub.

Features of MongoDB

One of the most important reasons for the popularity of MongoDB is that it is a JSON-friendly database. It means that documents are stored and retrieved from MongoDB as JavaScript objects. Internally, this JSON data gets converted to BSON format while getting persisted to the system. So, this gives an extreme flexibility where we can use the same data format from client to server and eventually to the database.

A typical document (record) in a MongoDB collection (table) might look like the following code:

$ mongo
> db.contacts.find({email: 'jason@kroltech.com'}).pretty()
{
   "email" : "jason@kroltech.com",
   "phone" : "123-456-7890",
   "gravatar" : "751e957d48e31841ff15d8fa0f1b0acf",
   "_id" : ObjectId("52fad824392f58ac2452c992"),
   "name" : {
      "first" : "Jason",
      "last" : "Krol"
   },
   "__v" : 0
}

Another important feature of MongoDB is its schemaless nature. With a relational database, you are required to define (ahead of time) the exact structure of the data being stored, which is termed as the schema. This means that you must have defined the exact number of columns, length, and data type for every field in a table, and that each field must always match that exact set of criteria. Mongo provides a flexible nature where the documents that you store into the database need not follow any schema unless the developer enforces it through the application level. This makes MongoDB a great fit for Agile-based development, as you could carry out modifications on the application schema on fly.

Other than the JavaScript-friendly nature, one other resemblance of MongoDB with Node.js is that it is also designed with highly concurrent applications with heavy read operations in mind.

MongoDB also introduces the concept of sharding, which makes it possible to scale the database horizontally as well as vertically. If the application owner needs to increase the database capabilities, they could add up more machines into the stack. This is a cheaper option compared to investing on RAM of a single machine, which will be the case in RDBMS solutions.

All the advantages that we discussed come with some impact on the consistency, as MongoDB does not strictly adhere to the RDBMS standards like ACID transactions. Also, if you end up creating a data model that might need too many JOIN operations, then MongoDB won't make a good fit as it is not designed with too many aggregations even though the aggregations are possible via the MongoDB aggregation framework. MongoDB may or may not be the right solution for your application. You should truly weigh the pros and cons of each technology before making a decision to determine which technology is right for you.

Node and MongoDB in the wild

Both Node and MongoDB are extremely popular and active in the development community. This is true for enterprises as well. Some of the biggest names in the Fortune 500 space have fully embraced Node to power their web applications. This is due in large part to the asynchronous nature of Node, which makes it a great alternative for high traffic, high I/O applications such as e-commerce websites and mobile applications.

Here's just a small list of some big companies that are working with Node:

  • PayPal
  • LinkedIn
  • eBay
  • Walmart
  • Yahoo!
  • Microsoft
  • Dow Jones
  • Uber
  • New York Times

MongoDB's use in the enterprise sector is equally as impressive and widespread, with an increasing number of companies adopting the leading NoSQL database server. Here's just a small list of some big companies that are working with MongoDB:

  • Cisco
  • Craigslist Inc.
  • Forbes
  • FourSquare
  • Intuit
  • McAfee
  • MTV
  • MetLife
  • Shutterfly
  • Under Armour

What to expect from this book

The remainder of this book is going to be a guided tour that walks you through creating a complete data-driven website. The website we create will feature almost every aspect of a typical large-scale web development project. The app will be developed using a popular Node.js framework called Express, and it will persist data using MongoDB. In the first few chapters, we will cover the groundwork involved in getting the core of the server up and serving content. This includes configuring your environment so you are up and running with Node and MongoDB, and a basic introduction to the core concepts of both technologies. Then, we will write a web server from scratch powered by ExpressJS, which will handle serving all of the necessary files for the website. From there, we will work with the Handlebars template engine to serve both static and dynamic HTML web pages. Diving deeper, we will make the application persistent by adding a data layer where the records for the website will be saved and retrieved via a MongoDB server.

We will cover writing a RESTful API so that other people can interact with your application. Finally, we will go into the details to see how to write and execute tests for all of your code. A summary is given in the following figure:

What to expect from this book

Wrapping up, we will take a brief detour as we examine some popular, merging frontend technologies that are becoming increasingly popular while writing SPAs. These technologies include Backbone.js, Angular, and Ember.js.

Last but not least, we will go into details about how to deploy your new website to the Internet using popular cloud-based hosting services such as Heroku and Amazon Web Services.

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Summary

In this chapter, we reviewed what is to be expected throughout the rest of this book. We discussed the amazing current state of JavaScript and how it can be used to power the full stack of a web application. Not that you needed any convincing in the first place, but I hope you're excited and ready to get started writing web applications using Node.js and MongoDB!

Next up, we will set up your development environment and get you up and running with Node, MongoDB, and npm as well as write and launch a quick Node app that uses MongoDB!

Left arrow icon Right arrow icon

Description

Node.js and MongoDB are quickly becoming one of the most popular tech stacks for the web. Powered by Google's V8 engine, Node.js caters to easily building fast, scalable network applications while MongoDB is the perfect fit as a scalable, high-performance, open source NoSQL database solution. Using these two technologies together, web applications can be built quickly and easily and deployed to the cloud with very little difficulty. The book will begin by introducing you to the groundwork needed to set up the development environment. Here, you will quickly run through the steps necessary to get the main application server up and running. Then you will see how to use Node.js to connect to a MongoDB database and perform data manipulations. From here on, the book will take you through integration with third-party tools for interaction with web apps. It then moves on to show you how to use controllers and view models to generate reusable code that will reduce development time. Toward the end of the book, we will cover tests to properly execute the code and some popular frameworks for developing web applications. By the end of the book, you will have a running web application developed with MongoDB and Node.js along with it's popular frameworks.

Who is this book for?

This book is designed for JavaScript developers of any skill level that want to get up and running using Node.js and MongoDB to build full-featured web applications. A basic understanding of JavaScript and HTML is the only requirement for this book.

What you will learn

  • Configure your development environment to use Node.js and MongoDB
  • Write and configure a web server using Node.js powered by the Express.js framework
  • Build dynamic HTML pages using the Handlebars template engine
  • Persist application data using MongoDB and Mongoose ODM
  • Test your code using automated testing tools such as the Mocha framework
  • Deploy the development environment to the cloud using services such as Heroku, Amazon Web Services, and Microsoft Azure
  • Explore SinglePage application frameworks to take your web applications to the next level

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 30, 2015
Length: 300 pages
Edition : 2nd
Language : English
ISBN-13 : 9781785287527
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 30, 2015
Length: 300 pages
Edition : 2nd
Language : English
ISBN-13 : 9781785287527
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 7,859.97
Mastering Node.js
₱2806.99
Web Development with MongoDB and NodeJS Second edition
₱2245.99
Learning Node.js for Mobile Application Development
₱2806.99
Total 7,859.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. Welcome to JavaScript in the Full Stack Chevron down icon Chevron up icon
2. Getting Up and Running Chevron down icon Chevron up icon
3. Node and MongoDB Basics Chevron down icon Chevron up icon
4. Introducing Express Chevron down icon Chevron up icon
5. Templating with Handlebars Chevron down icon Chevron up icon
6. Controllers and View Models Chevron down icon Chevron up icon
7. Persisting Data with MongoDB Chevron down icon Chevron up icon
8. Creating a RESTful API Chevron down icon Chevron up icon
9. Testing Your Code Chevron down icon Chevron up icon
10. Deploying with Cloud-Based Services Chevron down icon Chevron up icon
11. Single-Page Applications with Popular Frontend Frameworks Chevron down icon Chevron up icon
12. Popular Node.js Web Frameworks Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(6 Ratings)
5 star 66.7%
4 star 0%
3 star 33.3%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Chris C Jan 19, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I am a JavaScript developer learning Node & Express. i found this book very helpful. The author explains each step throughout the entire process of building an app which is very helpful. The book covers most areas of Express and Node and some advance topics. For me it was a good buy.
Amazon Verified review Amazon
Keith Smith Nov 20, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Clear and comprehensive coverage. A must read for anyone interested in using MongoDB with NodeJS!
Amazon Verified review Amazon
Hüseyin BABAL Dec 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As a reviewer of this book, I can say that this book is complete reference for the people who want to cover all the stuffs about Node.js and related technologies. After basic start with Javascript basics, all the basic terms like Non Blocking I/O are covered in a simple way supported with examples. At the end of this book, you will be able to create web applications with Express.js and MongoDB, design RESTful services, write unit and integration test to build high quality applications. One of the difficult thing about using Node.js is choosing frameworks for creating web applications, but you are lucky. There is also fancy comparison section about commonly used frameworks in this book.
Amazon Verified review Amazon
Rivalcoba Sep 27, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Uno de los mejores libros de desarrollo web con nodeJs, mediante un proyecto completo se explican paso a paso todos los elementos de una aplicación web.
Amazon Verified review Amazon
Amazon Customer Dec 14, 2015
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Update 12/20/15: Note that while I stand by my original notes (below), the second half of chapter 4 cleared some things up. I've updated my rating from 2 to 3 stars. If the rest of the book continues without more typos and sections in the wrong order, I'd up my rating again to 4 stars. I also submitted several of the typos I noticed, and got a notice from the publisher that the authors had accepted those corrections. I don't know if those corrections will make it into THIS edition, or if they'll only affect a next edition the authors might publish. Hopefully the former! So, if you download this book and bog down some in chapter 4, just try pushing through and keep going, and things may clear up for you some.This book was frustrating to use. The book's approach seems to be to rush the reader through the creation of an app, and only partially explain things along the way. I imagine that they may explain some of the mysteries later in the textbook, and that they want to rush you along to give you the satisfaction of having created something that works.However, I've found a number of typos and errors. That's a problem, because the reader is likely new to Node/MongoDB, since it's an introductory textbook. When the book instructs you to run the app so far and something goes wrong because of one of those errors, it's hard for the reader to know how to solve the problem, because the book hasn't explained how everything in the app actually works.In Chapter 4, for example, the book helps us create a very simple 'server.js' file, and run that file. So far, so good. The book does a decent job of explaining that file so far, what's in it, and why. Then the next section adds a 'configure.js' module, and this is where the problems start. The book says that the app should still run smoothly after updating the 'server' file and adding the 'configure' file. But the 'configure' code listed in the book has two semi-obvious syntactical typos. Even after correcting those, the app doesn't run correctly, because the 'configure' module is requiring a third module, './routes', which the book hasn't given us instructions for creating yet.The book gives the impression of not having been very well reviewed/edited. I'm nearly ready to give up on it. Maybe it will get clearer after chapter 4, and the outside reading I'll need to do to understand any poorly-structured parts will probably be good for me anyway. But I really can't recommend this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.