Incremental Rails to SPA Migration with Mock APIs
Table of Contents
- 1. Background
- 2. Scenario
- 2.1. Create a mock Rails application
- 2.2. Scaffold several objects
- 2.3. Document the external POST and GET endpoint
- 2.4. Create initial consumer of mock API
- 2.5. Return JSON rather than HTML
- 2.6. Load mock data
- 2.7. Validate the implementation with cUrl
- 2.8. Create the Swagger documentation
- 2.9. Create the route mocks for the Python
- 3. Links
- 4. Tools
1. Background
Provide a simple mechanism from creating a base Rails application with an incremental path to migrate to a SPA backing based on a namespace switch to /api.
The goal will be to keep all of the core business logic for persisting data in Rails but gradually move features to the front-end in either Angular or React.
2. Scenario
2.1. Create a mock Rails application
rails new appmigapi
2.4. Create initial consumer of mock API
yeoman new react-app
2.5. Return JSON rather than HTML
respond_to :json
2.6. Load mock data
group :development, :test do gem 'faker' end