Book Image

Web Development with MongoDB and Node - Third Edition

Book Image

Web Development with MongoDB and Node - Third Edition

Overview of this book

Node.js builds fast, scalable network applications while MongoDB is the perfect fit as a high-performance, open source NoSQL database solution. The combination of these two technologies offers high performance and scalability and helps in building fast, scalable network applications. Together they provide the power for manage any form of data as well as speed of delivery. This book will help you to get these two technologies working together to build web applications quickly and easily, with effortless deployment to the cloud. You will also learn about angular 4, which consumes pure JSON APOIs from a hapi server. The book begins by setting up your development environment, running you through the steps necessary to get the main application server up-and-running. Then you will see how to use Node.js to connect to a MongoDB database and perform data manipulations. From here on, the book will take you through integration with third-party tools to interact with web apps. You will see how to use controllers and view models to generate reusable code that will reduce development time. Toward the end, the book supplies tests to properly execute your code and take your skills to the next level with the most popular frameworks for developing web applications. By the end of the book, you will have a running web application developed with MongoDB, Node.js, and some of the most powerful and popular frameworks.
Table of Contents (19 chapters)
Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Chapter 8. Creating a RESTful API

Now that your application is complete and ready for the world to see, you can start thinking of ways to make it more popular. What if you want to allow external systems access rights to your data in a way such that they can mass produce inserts to your website without the need for users to visit the actual website? One example that comes to mind almost immediately is how users of another website, say www.facebook.com, could upload an image to Facebook and have it automatically uploaded to your website as well.

The only way to make a scenario like this possible is by providing an API to your data and the code that gives external developers access to a suite of tools that will allow them to perform actions without the need to interact with the actual web pages.

In this chapter, we will review the following topics:

  • Introducing RESTful APIs
  • Installing a few basic tools
  • Creating a basic API server and sample JSON data
  • Responding to GET requests
  • Updating data with POST...