Rails API Gateway
Please review the documentation repo; specifically the process documents:
- System dependencies
rvm
,rbenv
orasdf
for Ruby Version management.ruby-version
file should auto load correct ruby versionasdf
may need additional configuration
- Install Redis:
brew install redis
brew services start redis
orredis-server
- A Postgres database server
- recommended: Postgre.app - https://postgresapp.com/
- optionally installed using home brew:
brew install postgresql
- Clone this repository:
git clone git@github.com:vippetcare/api-gateway.git; cd ./api-gateway
- Create
.env.development.local
in root directory with the following values (see Environment Variables section below) - Setup
bundle
sh script/rebuild_development_database.sh
- NOTE: this will drop your development and test database
- Start the application:
rails s
- Open http://localhost:3111/ in a browser
- Running the application
- Start the application:
bundle exec rails s
- Start the application:
- Running tests and tooling
- ruby specs:
rspec spec
- ruby lint:
rubocop
- ruby specs:
NOTE: depending on your environment you may need to prefix your rails commands with bundle exec
or use bin/rails
Wellness
component (Engine)- integrates third party APIs that offer wellness plans
DbService
component (Engine)- segregates Postgres related models that serves engines and main app
- generate models, migrations on engine level
component/db_service
- run migrations on engine level
- all migrations have to be copied to main level app.
- run task from main level app:
- copy all migrations from all engines to main level app
rails railties:install:migrations
- copy migrations from db_service engine to main level app
rails db_service:install:migrations
- copy all migrations from all engines to main level app
Before making changes, copy pre-commit.sh
to the repo .git/hooks
folder using:
ln -s ../../pre-commit.sh .git/hooks/pre-commit
API Documentation using swagger is mounted at http://localhost:3111/vip-api-docs/index.html New specs must be added to the /spec/integration/ folder before they will be available.
After new specs are added run the rake task rake rswag:specs:swaggerize
While pairing you may want to use git pair
for your commits, it requires installing the gem
gem install pivotal_git_scripts
- See: https://github.com/pivotal/git_scripts
- Use
Time.current
(alias ofTime.zone.now
) instead ofTime.now
- Use
Date.current
instead ofDate.today
- Heroku pipelines are used for staging, deployments are automatic
- Heroku application is used for production, manually deployed using the UI
- AIRBRAKE_PROJECT_ID
- All non development environments (for exception notification)
- AIRBRAKE_PROJECT_KEY
- All non development environments (for exception notification)
- DATABASE_URL
- CI, staging and production only
- Optional in other environments as it overrides database.yml settings
- GATEWAY_USERNAME
- All environments
- Username to auth gateway to generate tokens
- GATEWAY_PASSWORD
- All environments
- Password to auth gateway to generate tokens
- HEROKU_APP_NAME
- Staging and production only
- JWT_TOKEN_EXPIRATION_IN_HOURS
- All environments
- RACK_ENV
- All environments, handled automatically
- RAILS_ENV
- All environments, handled automatically
- RAILS_LOG_TO_STDOUT
- All non development environments
- Automatically installed by Heroku
- RAILS_MAX_THREADS
- All environments, defaults in development
- The min threads setting allows your application to spin down resources when not under load. This feature is not needed on Heroku
- RAILS_SERVE_STATIC_FILES
- All non development environments
- Automatically installed by Heroku
- REDIS_URL
- All environments
- Automatically added in staging and production with Heroku Redis Addon
- optionally set in local env files
echo "REDIS_URL=redis://127.0.0.1:6379/1" >> .env.development.local
echo "REDIS_URL=redis://127.0.0.1:6379/0" >> .env.test.local
- SECRET_KEY_BASE
- All non development environments
- Automatically installed by Heroku
- WEB_CONCURRENCY
- All environments, defaults in development
- With a typical Rails memory footprint, you can expect to run 2-4 Puma worker processes on a free, hobby or standard-1x dyno
- WELLNESS_VCP_PASSWORD
- All environments
- optionally set in local env files
echo "WELLNESS_VCP_PASSWORD=XXXX" >> .env.development.local
echo "WELLNESS_VCP_PASSWORD=XXXX" >> .env.test.local
- where
XXXX
is demo password
- WELLNESS_VCP_USERNAME
- All environments
- optionally set in local env files
echo "WELLNESS_VCP_USERNAME=XXXX" >> .env.development.local
echo "WELLNESS_VCP_USERNAME=XXXX" >> .env.test.local
- where
XXXX
is demo username
- AWS_ACCESS_KEY_ID
- All environments
- set in local env files
- AWS_SECRET_ACCESS_KEY
- All environments
- set in local env files
- AWS_BUCKET_NAME
- All environments
- set in local env files
- AWS_REGION
- All environments
- set in local env files
-
bundle exec rake applications:cancel
- Starts a background job to retreive a list of contract applications present
- If application is older than 7 days and it has not already been completed, an attempt to cancel it is made
- Job can be run manually and accepts a list of status codes to cancel as well as a date cutoff
- Errors that cannot be automatically corrected are listed to assist with manual troubleshooting
-
bundle exec rake s3:validate
- Starts a background job to retrieve a list of new contracts from partner and checks that they have a corresponding agreement document in Amazon S3 bucket
- If a mismatch is present, the job attempts to download missing documents from partner and reupload
- Errors that cannot be automatically corrected are listed to assist with manual troubleshooting