Book Image

PhoneGap By Example

Book Image

PhoneGap By Example

Overview of this book

Table of Contents (17 chapters)
PhoneGap By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exploring technologies to build a REST API


The shortest way for us, as web developers, to build a REST API is to use a language we already know, JavaScript. Based on the selection, it is not hard to guess that we need to use Node.js and MongoDB. We already installed Node.js in Chapter 1, Installing and Configuring PhoneGap. Let's now take a closer look at what it is and how we can use it for our needs.

Understanding Node.js

The main advantages of Node.js are as follows:

  • It does everything asynchronously, because it uses an event-driven approach.

  • It uses the very fast JavaScript V8 engine.

  • It shows very good performance, especially on scalable architectures.

  • Same JavaScript code can be used on both client and server sides. For example, we can use the same JSON structures and the same validation code on clients and servers.

If you write a lot of code, sooner or later, you start realizing that your logic should be split into different modules. In most languages, this is done via classes, packages...