A Ruby on Rails api-only app with JWT token authentication that exposes a basic CRUD API for managing contacts in a phonebook.
In order to create a new user just call POST /users with the mandatory fields, first_name, last_name, email, password.
Then try to login by visiting POST /sessions/authenticate and supplying the email and password of the user that was just created.
Copy the auth_token and keep it somewhere safe, now you can make calls to the contacts API by passing the auth_token as a header like so
Authorization:Bearer <auth_token>
-
POST /userswith the mandatory fields -
GET /contacts -
POST /contactswith mandatory fields -
GET /contacts/:id -
PUT /contacts/:id -
DELETE /contacts/:id
Also available as a postman collection
Firstly you will need ruby installed ideally by using a version manager like rbenv that lets you have different versions of ruby per directory. This app is using Ruby 2.5.1 and Rails 5.1.7 it is also depending on postgreSQL to be installed on the host machine.
Run bundle install to install all the gems listed in the Gemfile.
A visual representation of the database is available under the schema.xml file just navigate
to this URL and paste the contents of the file in the load window.
Make sure that the database credentials listed in config/database.yml match the ones for the local database user.
In order to create the database run rails db:create followed by rails db:schema:load
In order to run the test suite just run bundle exec spec
You can start the application server called 'Puma' by running rails s in your terminal and stop it by hitting CTRL + c.
After making any changes to configuration the server has to be restarted for the changes to take effect.
- validate phone numbers with telephone_number
- Add search endpoint in the contacts API
- Introduce permission groups so only admin level users can manage other users