Book Image

RESTful Web API Design with Node.js - Second Edition

By : Valentin Bojinov
Book Image

RESTful Web API Design with Node.js - Second Edition

By: Valentin Bojinov

Overview of this book

In this era of cloud computing, every data provisioning solution is built in a scalable and fail-safe way. Thus, when building RESTful services, the right choice for the underlying platform is vital. Node.js, with its asynchronous, event-driven architecture, is exactly the right choice to build RESTful APIs. This book will help you enrich your development skills to create scalable, server-side, RESTful applications based on the Node.js platform. Starting with the fundamentals of REST, you will understand why RESTful web services are better data provisioning solution than other technologies. You will start setting up a development environment by installing Node.js, Express.js, and other modules. Next, you will write a simple HTTP request handler and create and test Node.js modules using automated tests and mock objects. You will then have to choose the most appropriate data storage type, having options between a key/value or document data store, and also you will implement automated tests for it. This module will evolve chapter by chapter until it turns into a full-fledged and secure Restful service.
Table of Contents (12 chapters)
RESTful Web API Design with Node.js - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Extensibility and versioning


We've already defined a few basic versioning rules in Chapter 3, Building a Typical Web API. Let's apply them to the test API version implemented in the previous chapter. Our starting point would be to enable the current consumers of the API to continue using the same version on different URIs. This would keep them backward compatible until they test and adopt the new version.

Keeping a REST API stable is not a question of only moving one endpoint from one URI to another. It doesn't make sense to perform redirection and afterwards have an API that behaves differently. Thus, we need to ensure that the behavior of the moved endpoint stays the same, as it has been at the previous location. To ensure that we don't change the previously implemented behavior, let's keep the current behavior from contactdataservice.js module to a new module by renaming the file to contactdataservice_1.js. Then make a copy of it to a module contactdataservice_2.js, where we will introduce...