Book Image

Node.js By Example

Book Image

Node.js By Example

Overview of this book

Table of Contents (18 chapters)
Node.js By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Node.js is one of the present day's most popular technologies. Its growing community is known to produce a large number of modules every day. These modules can be used as building blocks for server-side applications. The fact that we use the same language (JavaScript) on both the server- and client-side make development fluent.

This book contains 11 chapters that contain a step-by-step guide to building a social network. Systems such as Facebook and Twitter are complex and challenging to develop. It is nice that we will learn what Node.js is capable of, but it is going to be much more interesting if we do that within a concrete context. The book covers basic phases such as the architecture and management of the assets' pipeline, and it discusses features such as users' friendship and real-time communication.

What this book covers

Chapter 1, Node.js Fundamentals, teaches the basics of Node.js, what stands behind the technology, and its module management system and package manager.

Chapter 2, Architecting the Project, reveals the power of build systems such as Gulp. Before starting with our social network, we will plan the project. We will talk about test-driven development and the Model-View-Controller pattern. The chapter will cover the Node.js modules that are needed to bootstrap the project.

Chapter 3, Managing Assets, covers the building of a web application. So, we have to deal with HTML, CSS, JavaScript, and images. In this chapter, we will go through the processes behind the serving of assets.

Chapter 4, Developing the Model-View-Controller Layers, is about the basic structure of our application. We will create classes for views, models, and controllers. In the next few chapters, we will use these classes as a base.

Chapter 5, Managing Users, is about implementing user registration, authorization, and profile management.

Chapter 6, Adding Friendship Capabilities, explains one of the main concepts behind modern social networks—friendship. The ability to find friends and follow their walls is an important part. This chapter is dedicated to the development of this relationship between users.

Chapter 7, Posting Content, states that the backbone of every social network is the content that users add into the system. In this chapter, we will implement the process of post making.

Chapter 8, Creating Pages and Events, states that providing the ability to users to create pages and events will make our social network more interesting. Users can add as many pages as they want. Other users will be able to join the newly created places in our network. We will also add code to collect statistics.

Chapter 9, Tagging, Sharing, and Liking, explains that besides posting and reviewing content, the users of a social network should be able to tag, share, and like posts. This chapter is dedicated to the development of these functions.

Chapter 10, Adding Real-time Chat, talks about the expectations of users, in today's world, to see everything that is happening right away. They want to communicate faster with each other. In this chapter, we will develop a real-time chat so that the users can send messages instantly.

Chapter 11, Testing the User Interface, explains that it is important to get the job done, but it is also important to cover working functionalities with tests. In this chapter, we will see how to test a user interface.

What you need for this book

The book is based on Node.js version 0.10.36. We will also use MongoDB (http://www.mongodb.org/) as a database and Ractive.js (http://www.ractivejs.org/) as a client-side framework.

Who this book is for

If you have knowledge of JavaScript and want to see how you can use it in the backend, this book is for you. It will lead you through the creation of a fairly complex social network. You will learn how to work with a database and create real-time communication channels.

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: "If the Ractive component has a friends property, then we will render a list of users."

A block of code is set as follows:

<li class="right"><a on-click="goto:logout">Logout</a></li>
<li class="right"><a on-click="goto:profile">Profile</a></li>
<li class="right"><a on-click="goto:find-friends">Find  friends</a></li>

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

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

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: "It shows their name and a Add as a friend button."

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.