Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexwebgr/phonebook
A Ruby on Rails api-only app with JWT token authentication that exposes a basic CRUD API for managing contacts in a phonebook.
https://github.com/alexwebgr/phonebook
api jwt rspec ruby ruby-on-rails
Last synced: 5 days ago
JSON representation
A Ruby on Rails api-only app with JWT token authentication that exposes a basic CRUD API for managing contacts in a phonebook.
- Host: GitHub
- URL: https://github.com/alexwebgr/phonebook
- Owner: alexwebgr
- Created: 2019-07-21T15:01:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-08-10T14:04:47.000Z (over 2 years ago)
- Last Synced: 2025-01-28T09:49:55.800Z (12 days ago)
- Topics: api, jwt, rspec, ruby, ruby-on-rails
- Language: Ruby
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The Ruby Phonebook
A Ruby on Rails api-only app with JWT token authentication that exposes a basic CRUD API for managing contacts in a phonebook.[Hosted in Heroku](https://sheltered-chamber-62543.herokuapp.com)
#### How to register a userIn 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 `#### Available endpoints
* `POST /users` with the mandatory fields* `GET /contacts`
* `POST /contacts` with mandatory fields
* `GET /contacts/:id`
* `PUT /contacts/:id`
* `DELETE /contacts/:id`Also available as a [postman collection](https://documenter.getpostman.com/view/1699252/SVSNKTQQ?version=latest)
#### Instructions for running the app locally
Firstly you will need ruby installed ideally by using a version manager like [rbenv](https://github.com/rbenv/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.
#### Database
A visual representation of the database is available under the `schema.xml` file just navigate
to this [URL](https://ondras.zarovi.cz/sql/demo/) 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`#### How to run the test suite
In order to run the test suite just run `bundle exec spec`#### Starting the app
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.#### Improvements
* validate phone numbers with [telephone_number](https://rubygems.org/gems/telephone_number)
* Add search endpoint in the contacts API
* Introduce permission groups so only admin level users can manage other users