Skip to content

peimelo/controlled_health_api

Repository files navigation

Controlled Health API Maintainability Tests

Controlled Health website API built with Ruby on Rails as API and using devise_token_auth.

Ruby version 3.0.4
Rails version 6.1.6.1
Database PostgreSQL

The frontend of this repository was built with Angular and is called controlled-health-frontend.

Configuration

git clone https://github.com/peimelo/controlled_health_api.git
cd controlled_health_api

# installation of dependencies
bundle install

# creation of database and tables
rails db:create
rails db:migrate

# load initial data
rails db:seed

# run the project
rails s

Configuration for Production

# delete the config/credentials.yml.enc file
rm config/credentials.yml.enc

# run the command to create credentials and master key (replace 'code' if you don't use VS Code)
EDITOR="code --wait" bin/rails credentials:edit

Add the information below in the credentials to configure the email used by the Devise gem and Exception Notification gem (replace with the values ​​you want):

# ... your content above

gmail:
  user_name: your@email.com
  password: your_password

exception_recipients: exceptions@example.com

Save and close the config/credentials.yml.enc file.

If you want to use another email provider, change it in the file config/environments/production.rb.

To configure default_confirm_success_url, change it in the file config/initializers/devise_token_auth.rb.

To configure CORS origins, change it in the file config/initializers/cors.rb.

To configure Exception Notification, change it in the file config/initializers/exception_notification.rb.

Tests

To run the tests:

bundle exec rspec

Configuration to use Docker

# upload the web and database instances
docker-compose up -d

# creation of tables
docker-compose exec web bundle exec rails db:migrate

# load initial data
docker-compose exec web bundle exec rails db:seed

# creation of database and test tables
docker-compose exec web bundle exec rails db:create RAILS_ENV=test
docker-compose exec web bundle exec rails db:migrate RAILS_ENV=test

# run the tests
docker-compose exec web bundle exec rspec

# stop the instances
docker-compose stop