Streamlining Integration of Single Page Applications (SPA) into Existing Backends: Tools and Best Practices

Table of Contents

Background

When integrating SPA into an existing backend there are a number of tools that can be used to reduce the pain of performing the work.

Tools

Process

  1. Provide explicit notes on the exact HTTP expectations
  2. Provide notes on the routing expected from the application server
  3. Provide a single case of the request without and existing state
  4. Whitelist the route mapping through the proxy server
  5. Disable any mock front-end API
  6. Establish monitoring to go with #1

Integration

We'll focus initally on a scenario where we're able to have an explicit build step and that we want to have the developer experience be as seemless as possible when in either Rails or during the application development.

  • Rails provides some core functionality
  • Rails also provides api
  • Node provides a place for live loading files
  • Node provides a build infrastructure for creating a single main.js

Options

Symlink the deployments in public

Copy the files and check into version control in public

Copy the file and check into app/assets

Deploy build to S3, public, with day Expires

S3 then CloudFront with invalidations

S3, nginx proxy with gzip, CloudFront

NPM in Rails

SPA as gem to AssetPipeline

Testing

  • Name, Size (compressed), Size (uncompressed), Expires

Author: Jason Walsh

j@wal.sh

Last Updated: 2024-10-30 16:43:54