Book Image

Web Development with MongoDB and Node.js

By : Jason Krol
Book Image

Web Development with MongoDB and Node.js

By: Jason Krol

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

Preface

My goal while writing Web Development with MongDB and Node.js was simple: to empower you, the reader, with the tools and knowledge to be able to create web applications from scratch using Node.js and MongoDB.

In this book, we take a hands-on approach to building a complete, real-world, interactive web application. Each chapter will build upon the previous one, exposing new concepts, technologies, and best practices until finally ending with a completed application deployed to the cloud. Every line of code will be covered, and you are expected to code along with each chapter. Doing so will give you valuable insight into the world of web development using Node.js.

By the end of this book, I hope you have the expertise to tackle any project using Node.js and MongoDB and are limited only by your imagination!

What this book covers

Chapter 1, Welcome to JavaScript in the Full Stack, introduces you to the world of full stack JavaScript development and reviews what to expect in the remainder of the book.

Chapter 2, Getting Up and Running, walks you through the necessary steps to download, install, and configure your development environment.

Chapter 3, Node and MongoDB Basics, is a brief introduction to the basics of JavaScript, Node.js, and MongoDB.

Chapter 4, Writing an Express.js Server, introduces you to the Express.js Node.js Web Framework and is a walkthrough of the code necessary to write the main application server.

Chapter 5, Dynamic HTML with Handlebars, teaches you how to create dynamic HTML pages using Handlebars, the popular template-rendering engine.

Chapter 6, Controllers and View Models, walks you through writing the Controllers and View Models for the main application, the core of the application's functionalities.

Chapter 7, Persisting Data with MongoDB, continues with our Controllers and View Models, where we wrap all of the logic using Mongoose with MongoDB as the main data layer for the application.

Chapter 8, Creating a RESTful API, reviews the concepts behind REST APIs and introduces the Postman REST Client tool to test and interact with our own custom Node.js API.

Chapter 9, Testing Your Code, introduces the tools and techniques to write automated tests for our Node.js code.

Chapter 10, Deploying with Cloud-based Services, is a step-by-step walkthrough of deploying your application to a number of popular cloud-based hosting services such as Heroku, Microsoft Azure, and Amazon's AWS.

Chapter 11, Single Page Applications with Popular Frontend Frameworks, takes a look at the current trend in thick client applications by learning more about popular frontend single application frameworks such as Ember.js, AngularJS, and Backbone.js. Additionally, you will learn about the popular build tools frontend developers use to make their lives easier.

Chapter 12, Popular Node.js Web Frameworks, takes a look at some very popular and robust alternatives such as Meteor and Sails, even though Express.js is one of the most popular web frameworks for Node.

What you need for this book

In this book, the following software will be required:

  • Operating systems:

    • Windows XP or superior

    • Mac OS X or superior

    • Linux

  • Miscellaneous:

    • A standard text editor of choice

    • A web browser, preferably Google Chrome

  • A command-line terminal of choice

Who this book is for

This book is designed for 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.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Make sure you've npm installed all of the required modules for this chapter and that they are saved to your package.json file."

A block of code is set as follows:

models.Image.aggregate({ $group : {
    _id : '1',
    viewsTotal : { $sum : '$views' }
}}, function(err, result) {
    var viewsTotal = 0;
    if (result.length > 0) {
        viewsTotal += result[0].viewsTotal;
    }
    next(null, viewsTotal);
});

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

.upload-button {
    border-bottom: solid 2px #005A8B;
    background: transparent $sprite-bg no-repeat;
    @include radius(4px);
    cursor: pointer;

Any command-line input or output is written as follows:

$ node server.js
Server up: http://localhost:3300
Mongoose connected.

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Users demand more from their apps these days, and if you think about the application we've written, the Like button is a perfect example."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. 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.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.