Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Table of Contents (17 chapters)
JavaScript at Scale
About the Author
About the Reviewers

Decoupling the backend

If we need any further motivation that JavaScript is no longer just for scriptable web pages, look no further than NodeJS. It doesn't require the full browser environment, just the V8 JavaScript engine. Node was created primarily as a backend server environment, but it still serves as a great showcase for how far JavaScript as a language has come. In the same vein, we want our code to be portable, running with any backend infrastructure we can throw at it.

In this section, we'll look at the reasons why we want to loosen the coupling between our frontend JavaScript code, and the APIs it talks to in the backend. We'll then introduce the first steps to mocking APIs, negating the need for a backend entirely.

Mocking the backend API

If we're developing a large scale JavaScript application, we'll have the beginnings of a backend infrastructure. So why then, would we consider detaching our code from that backend so that it no longer depends on it? It's always a good idea to...