Book Image

PhoneGap for Enterprise

By : Kerri Shotts
Book Image

PhoneGap for Enterprise

By: Kerri Shotts

Overview of this book

Table of Contents (16 chapters)
PhoneGap for Enterprise
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. Building the Middle-Tier

If you browse any Cordova/PhoneGap forum, you'll often come across posts asking how to connect to and query a backend database. In this chapter, we will look at the reasons why it is necessary to interact with your backend database using an intermediary service. If the business logic resides within the database, the middle-tier might be a very simple layer wrapping the data store, but it can also implement a significant portion of business logic as well. The middle-tier also usually handles session authentication logic.

Although many enterprise projects will already have a middle-tier in place, it's useful to understand how a middle-tier works, and how to implement one if you ever need to build a solution from the ground up.

In this chapter, we'll focus heavily on these topics:

  • Typical middle-tier architecture

  • Designing a RESTful-like API

  • Implementing a RESTful-like hypermedia API using Node.js

  • Connecting to the backend database

  • Executing queries

  • Handling authentication...