You are previewing Learning Node.js for Mobile Application Development.
O'Reilly logo
Learning Node.js for Mobile Application Development

Book Description

Make use of Node.js to learn the development of a simple yet scalable cross-platform mobile application

About This Book

  • Use Node.js to satisfy the core backend requirements of modern apps, including user management, security, data access, and real-time data communication

  • Build practical real-world mobile applications, which will give you the necessary knowledge to build your very own mobile solutions

  • Step-by-step development of projects using Ionic Framework as the frontend and Node.js for the backend supported by a MongoDB database

  • 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 pains of understanding the languages and native frameworks that form an integral part of developing for different mobile platforms.

    This book is also for you if you are a developer who wants to capitalize on the MobileFirst strategy and so are going to use JavaScript for your complete stack.

    What You Will Learn

  • Develop an API from scratch

  • Set up a MongoDB Database as part of your mobile application backend

  • Deploy a cross-platform mobile application from the command line

  • Incorporate features within your mobile application that use native phone features such as a gyroscope, GPS, and accelerometer

  • Implement mobile applications that use web-enabled APIs

  • Build a mobile application with real-time chat messaging features

  • Develop a secure mobile application that is capable of functioning with real-time data

  • In Detail

    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, which means that developers can use the same language to write backend code. Also, it’s increasingly being seen as a "modern" replacement for PHP in web development, which relies on fast-paced data exchange. The growing community and the large amount of available modules makes Node.js one of the most attractive development environments.

    This book takes a step-wise and incremental approach toward developing cross-platform mobile technologies using existing web technologies. This will allow you to truly understand and become proficient in developing cross-platform mobile applications with Node.js, Ionic Framework, and MongoDB.

    The book starts off by introducing all the necessary requirements and knowledge to build a mobile application with a companion web service. It covers the ability to create an API from scratch and implement a comprehensive user database that will give you the opportunity to offer a mobile application with a personalized experience.

    Midway through the book, you will learn the basic processes to create a successful mobile application. You will also gain higher-level knowledge, allowing you to develop a functional and secure mobile application to ensure a seamless user experience for end users.

    Finally, the book ends with more advanced projects, which will bring together all the knowledge and expertise developed in the previous chapters to create a practical and functional mobile-application that has useful real-world features.

    Style and approach

    This book is an easy-to-follow guide that takes a step-wise approach in giving expertise and knowledge to help you truly understand what is needed to create a memorable user experience for end users. Each topic is placed in the context of the bigger picture, that is, to create cross-platform mobile applications using existing technologies.

    Downloading the example code for this book. 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 code file.

    Table of Contents

    1. Learning Node.js for Mobile Application Development
      1. Table of Contents
      2. Learning Node.js for Mobile Application Development
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Setting Up Your Workspace
        1. The Node.js backend
        2. Installing Node.js on different systems
          1. Windows
          2. Linux
          3. Ubuntu/Debian
          4. Fedora/RHEL/CentOS
          5. Verifying your installation
          6. Mac OS X
          7. Verifying your installation
        3. Setting up the Ionic framework and Cordova for Mac OS X
        4. Setting up the Ionic framework and Cordova for Windows
          1. Setting up the platform dependencies
            1. Installing Java
        5. Setting up Android Studio for Android, Mac, and Windows
        6. Setting up the Android Software Development Kit
        7. Setting up your physical Android device for development
          1. Enabling Developer options
          2. Enabling USB debugging
          3. Trusting a computer with installed IDE using secure USB debugging (devices with Android 4.4.2)
        8. Setting up the Environment Variables on Windows 7 and higher
        9. Setting up the Environment Variables for iOS on Mac OS X
          1. Installing the iOS SDK
        10. MongoDB
          1. Installation of MongoDB on different Operating System
            1. Windows
            2. Linux
            3. Ubuntu
            4. Fedora/RHEL/CentOS
          2. Starting MongoDB
            1. Mac OS X
              1. Connecting to MongoDB
            2. Windows
            3. Linux and OS X
        11. Summary
      9. 2. Configuring Persistence with MongoDB
        1. Learning outcomes of MongoDB
        2. An introduction to MongoDB
          1. Documents
          2. Collections
          3. Databases
          4. An example – a product order database
        3. Connecting to MongoDB
          1. Linux and Mac OS X
          2. Windows
        4. Creating a database
        5. Creating our collections
        6. Creating relations between documents
        7. Querying MongoDB
          1. Searching by ID
          2. Searching by property value
        8. Advanced queries
        9. Connecting MongoDB and Node.js
          1. Setting up a basic project
          2. Connecting to MongoDB
        10. Summary
      10. 3. Creating an API
        1. Learning outcomes of the RESTful API
        2. RESTing easy
        3. It's all hypermedia
          1. GET
            1. GET all
            2. GET by ID
          2. POST
          3. PUT
          4. DELETE
        4. Building a RESTful API with Node.js
          1. Setting up the RESTful API
          2. The HTTP module
          3. Dissecting the HTTP server
          4. Returning JSON
        5. Implementing our GET handlers
          1. Implementing a router
          2. Implementing our POST handlers
          3. Implementing the DELETE and PUT handlers
          4. Testing the API
        6. Moving forward
        7. Summary
      11. 4. Securing Your Backend
        1. Understanding the outcomes of token-based authentication
          1. The theoretical bit
          2. A small token of trust
          3. Playing your role
          4. Putting it all together
          5. Implementation
        2. Adding the new collections
        3. Adding an authentication module
          1. Creating functions to register and help users log in
            1. Registering users
            2. Enabling users to log in
          2. Extending our API
          3. OAuth
          4. Time-stamped access tokens
          5. Hashing passwords
        4. Summary
      12. 5. Real-Time Data and WebSockets
        1. Polling
        2. WebSockets
        3. Using WebSockets in Node.js
          1. Setting up our project
          2. Installing socket.io
          3. Creating a chat interface
          4. A basic file server
        4. An alternate chat
        5. The efficient serving of static files
        6. Summary
      13. 6. Introducing Ionic
        1. Setting up your Ionic web account
        2. Creating your first Ionic application
        3. Checking out your Ionic applications with Ionic View
          1. Installing Ionic View on Android
          2. Installing Ionic View on iOS
          3. Testing your application on the iOS Ionic View App
          4. Testing your application on Android
          5. Sharing your application with collaborators
        4. Going further
        5. Summary
      14. 7. Building User Interfaces
        1. The structure of an Ionic project
        2. Introducing AngularJS
          1. The structure of an Angular app
          2. Modules
            1. Modules within modules within modules
            2. Services, controllers, and other beasts
          3. The Angular MVC pattern
            1. The view
            2. The controller
            3. The model
          4. Putting it all together
        3. Modifying an Ionic project
          1. Modifying the header
          2. Modifying the tab colour, icons, and names
          3. Modifying our pages
        4. Adding a new tab
          1. Creating a new controller
          2. Creating a view
          3. Adding a state for the new tab
          4. Testing the newly created tab
        5. Going further
        6. Summary
      15. 8. Making Our App Interactive
        1. Creating a new project
        2. Creating a basic MVC project
          1. Creating the view
            1. Creating the list view
          2. Creating the controller
          3. Connecting the view and controller
          4. Testing the connection
          5. Creating the model
            1. Services
              1. Creating services
            2. Creating a factory
        3. Accessing the device data
          1. Accessing native services
          2. ngCordova
          3. Adding Cordova contacts to our factory
        4. Building for native devices
          1. Android
            1. Emulator
            2. A physical device
        5. The list view revisited
        6. Summary
      16. 9. Accessing Native Phone Features
        1. Creating the project
          1. Creating the basic app structure
          2. Integrating Google Maps into the app
        2. Angular directives
          1. Creating directives
          2. Restricting directives
          3. Scope isolation
          4. DOM manipulation
        3. Putting it all together
        4. Adding geolocation via GPS
        5. Summary
      17. 10. Working with APIs
        1. Setting up Parse
        2. Setting up the Ionic project
        3. Connecting Parse to our project
          1. Defining app states
          2. Creating controllers and templates
        4. Testing our application
        5. Summary
      18. 11. Working with Security
        1. An overview of client-side security
          1. Client-side security is a convenience
          2. The basic components of client-side security
        2. Building a secure app
          1. Starting off
          2. A basic authentication service
            1. The login function
          3. The isAuthenticated function
            1. The getCurrent function
          4. Implementing route authentication
        3. Summary
      19. 12. Working with Real-Time Data
        1. A refresher – WebSockets
        2. Getting the lay of the land
          1. What we will need
        3. Creating the server
        4. Building the chat app
          1. Setting up the basic app structure
          2. The input section
          3. The message view
          4. The ChatService function
          5. Adding WebSockets to the mix
          6. Updating the chat view
        5. Going further
        6. Summary
      20. 13. Building an Advanced Chat App
        1. We need some room!
        2. Namespaces
        3. Creating a multiroom chat application
          1. Configuring the basic layout
          2. Building the server
        4. Summary
      21. 14. Creating an E-Commerce Application Using the Ionic Framework
        1. Designing our application
          1. Creating an Ionic project
          2. Implementing our designs
          3. Setting up the product API
          4. Connecting the product API to our Ionic app
        2. Summary
      22. Index