This project is part of the Microverse Ruby on Rails curriculum!
Explore the docs »
Report Bug
·
Request Feature
This is a tracker API, and has been given an individual theme to keep track of workout measurements of the login users, also only the administrator users can manage the exercises.
This is the final Capstone project of the Microverse Curriculum.
Watch the walkthrough video to see how to use it in your computer
https://www.loom.com/share/1fa671b5e0584f3f82b0c27e9640cc54
The documentation was built using raddocs and swagger
To get a local copy up and running follow these simple example steps.
Ruby: 2.7.0 Rails: 5.2.4
Install gems with:
bundle install
Setup database with:
rails db:migrate
Start server with:
rails server
Install the HTTP client of your preference to use it, I used httpie
The following command will create an login a new user in the database
$ http :3000/v1/signup name=maru email=maru@email.com password=foobar password_confirmation=foobar
Users Log in with their email and password
$ http :3000/v1/login email=maru@email.com password=foobar
to create a new Exercise you first have to create an admin user to do that you have to do the following:
Open a rails console and update the user you want to set as admin this way:
$ rails c
> User.find_by(email: 'maru@email.com').update(admin: true)
> exit
After that you have to first login the user and copy the auth_token somewhere
$ http :3000/v1/login email=maru@email.com password=foobar
Finally we'll create a new exercise this way (paste the auth_token in the Authorization header)
$ http :3000/v1/exercises name=Squats user_id=1 \
Authorization:'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1OTEzMzMzOTl9.XLb1MX7E4293U6GzUi_lFxxBmAMcAZpcmapO7h8X92E'
To see all the exercises created in the database you don't need to be logged in just type the following command
$ http :3000/v1/exercises
No authentication is needed to see an specific exercise
$ http :3000/v1/exercises/2
To create a measurement an user has to be logged in and that user can only create his/her own measurement
Login the user (admin or not) and copy the auth_token somewhere
$ http :3000/v1/login email=audrey@email.com password=foobar
Now we'll paste it in the Authentication header for creating measurement
$ http :3000/v1/users/2/measurements description=Repetitions amount=10 exercise_id=1 \
Authorization:'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJleHAiOjE1OTQ0OTE0Nzd9.QkhAKA-Oft6reyvCw5tGHgLkD6bRDpsWb_iKX8tef6s'
To see all the measurements a user must be logged in and its only possible to see the measurements created by the logged in user, we'll use the same authentication as the step before
$ http :3000/v1/users/2/measurements Authorization:'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJleHAiOjE1OTQ0OTE0Nzd9.QkhAKA-Oft6reyvCw5tGHgLkD6bRDpsWb_iKX8tef6s'
Same as the step before only difference is we have to specify the measurement id just like we did in the Exercise one
$ http :3000/v1/users/2/measurements/1 Authorization:'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJleHAiOjE1OTQ0OTE0Nzd9.QkhAKA-Oft6reyvCw5tGHgLkD6bRDpsWb_iKX8tef6s'
to run the test cases do:
rspec spec/ --exclude-pattern integration/*
to update the raddocs documentation run:
rake docs:generate
to update the swagger documentation run:
rake rswag:specs:swaggerize
- and go to localhost:3000/api_docs with your browser to get to the raddocs documentation
- or go to localhost:3000/api-docs with your browser to get to the swagger documentation
- The project raddocs documentation was deployed in Heroku
- The project swagger documentation was deployed in Heroku
This project was built using these technologies.
- Ruby 2.6.3
- Rails 6.0.2.1
- Rspec
- rspec_api_documentation
- raddocs
- swagger
- Rubocop
- Ubuntu 18.4+
- Stickler
- VsCode
María Eugenia Quemé - @MaruKK - @euqueme - euqueme@gmail.com
Project Link
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
- Microverse
- Heroku
- The Best readme Template
- Austin Kabiru
- A D Vishnu Prasad
- How to document REST APIs with Swagger and Ruby on Rails
- Versioning a Rails API
This project is MIT licensed.