Skip to content

Latest commit

 

History

History
300 lines (213 loc) · 8.89 KB

README.md

File metadata and controls

300 lines (213 loc) · 8.89 KB

Contributors Forks Stargazers Issues Hireable


Logo

Exercise Tracker API Final Capstone project

This project is part of the Microverse Ruby on Rails curriculum!
Explore the docs »

Report Bug · Request Feature

Table of Contents

About The Project

asciicast

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.

Documentation

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

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Ruby: 2.7.0 Rails: 5.2.4

Setup

Install gems with:

bundle install

Setup database with:

rails db:migrate

Usage

Start server with:

rails server

Install the HTTP client of your preference to use it, I used httpie

Signup

The following command will create an login a new user in the database

$ http :3000/v1/signup name=maru [email protected] password=foobar password_confirmation=foobar

screenshot

Login

Users Log in with their email and password

$ http :3000/v1/login [email protected] password=foobar

screenshot

Create Exercise

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: '[email protected]').update(admin: true)
> exit

screenshot

After that you have to first login the user and copy the auth_token somewhere

$ http :3000/v1/login [email protected] password=foobar

screenshot

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'

screenshot

Exercises index

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

screenshot

Exercises show

No authentication is needed to see an specific exercise

$ http :3000/v1/exercises/2

screenshot

Create Measurement

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 protected] password=foobar

screenshot

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'

screenshot

All Measurements

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'

screenshot

Show Measurement

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'

screenshot

Run tests

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

Deployment

  • The project raddocs documentation was deployed in Heroku
  • The project swagger documentation was deployed in Heroku

Built With

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

Authors

María Eugenia Quemé - @MaruKK - @euqueme - [email protected]

Project Link

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

Acknowledgements

📝 License

This project is MIT licensed.