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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

URI parts and patterns


With large scale JavaScript applications, a lot of thought goes into the router component. We also need to put a lot of thought into the URIs themselves. What are they composed of? Are they consistent throughout the application? What makes a bad URI? Veering in the wrong direction on any of these considerations makes scaling the addressability of our application difficult.

Encoding information

The point of a URI is that a client can just pass it to our application, and it contains enough information that something useful can be done with it. The simplest URI just points to a resource type, or a static location within an app—/users or /home are respective examples of these types of URIs. Using this information, our router can trigger a route event, and a callback function is triggered. These callbacks wouldn't even require any arguments—they just know what to do because there's no variability.

On the other hand, router callback functions may need a bit of context. This...