Book Image

Learning Node.js for Mobile Application Development

Book Image

Learning Node.js for Mobile Application Development

Overview of this book

Table of Contents (21 chapters)
Learning Node.js for Mobile Application Development
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
14
Creating an E-Commerce Application Using the Ionic Framework
Index

Preface

Node.js is a massively popular JavaScript library that lets you use JavaScript to easily program scalable network applications and web services. People approaching Node.js for the first time are often attracted by its efficiency, scalability, and the fact that it's based on JavaScript, the language of the Web. This means that developers can use the same language to write backend code. Also, it's increasingly being looked upon as a modern replacement for PHP in web development, which relies on fast-paced data exchange. This growing community and the large amount of available modules makes Node.js one of the most attractive development environments.

What this book covers

Chapter 1, Setting Up Your Workspace, explains how to set up your work environment to develop cross-platform applications by using the Ionic framework as the frontend tool, Node.js for the backend, and the integrated development environment, Atom.

Chapter 2, Configuring Persistence with MongoDB, goes through the necessary configurations that are needed to make an instance of MongoDB work with Node.js. You will learn how to set up security and a database, install the relevant MongoDB driver for Node.js, and communicate with the database from a Node.js instance.

Chapter 3, Creating an API, looks at how we can set up a uniform interface for sending and receiving data and basic functionality on the Node.js server by building an API (Application Programming Interface) that exposes it. We will cover the basic REST topics and show you how to configure routes to perform simple read/write operations on our data.

Chapter 4, Securing Your Backend, shows that this type of remedies can be achieved by building a basic security mechanism in order to control user access. Specifically, we will deal with token-based authentication and show you how this makes it easy to limit access to your backend. In doing so, we will introduce the concept of roles and how they figure in our authentication scheme.

Chapter 5, Real-Time Data and WebSockets, shows you how to enable real-time data communication using WebSockets. This will allow your server to directly communicate with connected clients without having to perform polling on the client side.

Chapter 6, Introducing Ionic, covers all the basic essentials that are needed to set up a working environment, which is required to efficiently create and share Ionic apps.

Chapter 7, Building User Interfaces, takes the template project that we created in the past few chapters and modifies it to something closer to what we envisioned by altering the appearance of the user interface. In addition to this, we will also start experimenting with the Ionic project code to deeply understand what the project is made up of.

Chapter 8, Making Our App Interactive, covers a lot of ground, going into the details of AngularJS and learning more about the interaction of the model, view, and controller. We will also see how to use the Cordova plugins and ngCordova in order to access native features. Finally, we will also have a look at how to create services and use them in order to serve data to the users.

Chapter 9, Accessing Native Phone Features, discusses how to directly work with the Google Maps API in order to render and work with maps.

Chapter 10, Working with APIs, explores how to access external APIs in order to send and retrieve data. You will learn how to encode/decode data to/from JSON in our app in order to provide a standard interface for processing.

Chapter 11, Working with Security, introduces the concept of security in mobile apps in the context of authenticating and authorizing local users. We will have a look at how to implement a common login feature, which contacts a remote server (run by Node.js, of course!) in order to verify that a given pair of user credentials is correct. We then use this information in order to grant the user access to the rest of the application.

Chapter 12, Working with Real-Time Data, covers how to set up WebSocket communication through the mobile app in order to subscribe to dynamic notifications from a server. We will elaborate on how this helps us develop truly dynamic applications, such as chat apps. This chapter will further introduce the concept of push notifications, which will allow our app to get updates from a server on a dynamic basis.

Chapter 13, Building an Advanced Chat App, expands this mobile app and makes it more advanced by adding the features of chat rooms and notifications. In doing so, we will demonstrate how the concept of namespacing works on socket.io, which is one of the most important aspects of this library.

Chapter 14, Creating an E-Commerce Application Using the Ionic Framework, brings together the knowledge that you have accumulated from this book and implements it in an easy-to-use Ionic framework that can be used in your very own projects.

What you need for this book

You'll need the following software:

  • Android Studio

  • Android Software Development Kit

  • The Ionic framework

  • MongoDB

  • Atom

  • XCode

Who this book is for

This book is intended for web developers of all levels of expertise who want to deep dive into cross-platform mobile application development without going through the pain of understanding the languages and native frameworks that form an integral part of developing for different mobile platforms.

This book is also for developers who want to capitalize on the Mobile First strategy and who are going to use JavaScript for their complete stack.

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: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

angular.module('supernav.controllers', [])
.controller('MapCtrl', function ($scope) {
  $scope.mapCreated = function (map) {
    $scope.map = map;
  };
});

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

.state('app.scala', {
  url: '/scala',
  views: {
    'scala-view': {
      templateUrl: 'templates/app-chat.html',
      controller: 'ChatController',
      resolve: {
        chatRoom: function () {
          return 'scala';
        }
      }
    }
  }
});

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

console.log('Hello World!');

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: "Conclude this process by clicking on Create Column, and we are done!".

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.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: http://www.packtpub.com/sites/default/files/downloads/1453OT_ColorImages.pdf.

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 erratasubmissionform 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.