Book Image

Web Development with MongoDB and NodeJS Second edition

Book Image

Web Development with MongoDB and NodeJS Second edition

Overview of this book

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

Preface

Node.js and MongoDB are quickly becoming very 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 their popular frameworks.

What this book covers

Chapter 1, Welcome to JavaScript in Full Stack, introduces you to Node.js and the advantages of writing Javascript on the backend. In addition to this, it will explain the overall architecture of the application you are going to build using this book.

Chapter 2, Getting Up and Running, explains how to set up the development environments for Node.js and MongoDB. You will also be verifying that everything is set up properly by writing a sample app and running it.

Chapter 3, Node and MongoDB Basics, teaches you about the fundamental concepts of JavaScript, Node.js, and MongoDB in this chapter. It will introduce you to NodeJS and the various concepts around it, as well as MongoDB and its basic shell for CRUD operations.

Chapter 4, Introducing Express.js, introduces you to the Express framework and its various components It also walks you through how you will be organizing the basic application you are building with this framework. It will give you a detailed overview of the MVC components of Express.js too.

Chapter 5, Templating with Handlebars, introduces you to the concept of using a templating engine and handlebars. Also, it shows you how to use handlebars in your application as a templating engine.

Chapter 6, Controllers and View Models, shows you how to organize the code for the sample application you build into the controllers and views of Express. It will introduce you to the MVC concepts indirectly via introducing the need of separating the code into various modules and utilizing the Express framework.

Chapter 7, Persisting Data with MongoDB, shows you how to connect to the MongoDB server from the Node.js application you are building. It will also introduce you to the concept of ODM, the most popular one being Mongoose.

Chapter 8, Creating a RESTful API, introduces you to RESTful APIs. Also, it shows you the importance of RESTful wrapper for the application. Then, it will teach you how to can change the current application to a REST API based application.

Chapter 9, Testing Your Code, shows you why you need testing incorporated with your application and also what you should keep in mind for the testability of the code written.

Chapter 10, Deploying with Cloud-Based Services, discusses the options for hosting the Node.js MongoDB application you are building. It also compares the various PaaS solutions available in the market.

Chapter 11, Single-Page Applications with Popular Frontend Frameworks, discusses Single Page Applications. Also, you will analyze the popular frontend frameworks available. You will have a look at other frontend aspects such as the automation tools and transpilers available.

Chapter 12, Popular Node.js Web Frameworks, covers the various web frameworks available on Node.js, other than Express, which you will be using to build the application in this book. You will analyze various web frameworks such as Meteor, Sails, Koa, Hapi, and Flatiron.

What you need for this book

You will need:

  • A computer running OS X, Windows, or Linux

  • Samba 4.x Server software

Who this book is 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.

Conventions

In this book, you will find a number of text styles 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: "The function that actually logs Three is known as a callback to the setTimeout function."

A block of code is set as follows:

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

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

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            Newest Images
        </h3>
    </div>
    <div class="panel-body">
        {{#each images}}
            <div class="col-md-4 text-center" style="padding-bottom: 1em;"><a href="/images/{{ uniqueId }}"><img src="/public/upload/{{filename}}" alt="{{title}}" style="width: 175px; height: 175px;"  class="img-thumbnail"></a></div>
        {{/each}}
    </div>
</div>

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

$ command -parameters –etc

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: " You should see The image:index controller testing123 on the screen!"

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in 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 at 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 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.

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 could 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 to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.