SPA Integration
Table of Contents
- 1. Background
- 2. Tools
- 3. Process
- 4. Integration
- 4.1. Options
- 4.1.1. Symlink the deployments in public
- 4.1.2. Copy the files and check into version control in public
- 4.1.3. Copy the file and check into app/assets
- 4.1.4. Deploy build to S3, public, with day Expires
- 4.1.5. S3 then CloudFront with invalidations
- 4.1.6. S3, nginx proxy with gzip, CloudFront
- 4.1.7. NPM in Rails
- 4.1.8. SPA as gem to AssetPipeline
- 4.2. Testing
- 4.1. Options
- 5. Related
1. Background
2. Tools
verified
- Chrome "Copy as cUrl" https://developers.google.com/web/updates/2015/05/replay-a-network-request-in-curl?hl=en
3. Process
- Provide explicit notes on the exact HTTP expectations
- Provide notes on the routing expected from the application server
- Provide a single case of the request without and existing state
- Whitelist the route mapping through the proxy server
- Disable any mock front-end API
- Establish monitoring to go with #1
4. Integration
corrected
Rails does not provide an /api/ route namespace by default. `rails new --api` only trims middleware (drops cookie/session/flash) and makes controllers inherit from ActionController::API instead of ActionController::Base; any /api/ path has to be added manually in routes.rb. Source: Rails Guides, "Using Rails for API-only Applications" (guides.rubyonrails.org/api_app.html).
- Rails provides some core functionality
- Rails routes can be scoped under api, but only if added manually in routes.rb; Rails' API-only mode just trims middleware and swaps the controller base class
- Node provides a place for live loading files
- Node provides a build infrastructure for creating a single main.js
4.2. Testing
- Name, Size (compressed), Size (uncompressed), Expires
5. Related
- Incremental Rails to SPA Migration with Mock APIs – the migration before integration
- SPA Setup with Rails: JSON API and Angular – the API side
- The State of Caching – fingerprinting and CDNs for the assets