Building an API using Ruby on Rails 6 and authentication with devise token auth.
This API follows specification for JSON:API.
Ruby Version | 2.5.8 |
Rails Version | 6.0.4.6 |
Database | PostgreSQL |
# clone the project
git clone https://github.com/karinevieira/notebook-api.git
# enter the cloned directory
cd notebook-api
# run the project
docker-compose up --build
# create the development and test databases
rails db:create
# migrate tables to database
rails db:migrate
rails db:migrate RAILS_ENV=test
Open the browser at the address http://localhost:3000
To run tests, run the following command
rspec
Include the header for all requests:
Accept: 'application/vnd.api+json'
Include the headers for the follow requests:
- Logout
- Edit user
- Edit the user password
- Delete user
- Create contact
- Edit contact
- Delete contact
uid: 'userEmail'
client: 'userClient'
access-token: 'UserAccessToken'
Endpoints | Usage | Params |
---|---|---|
POST /api/auth |
Create a new user. | email: [String], password: [String], password_confirmation: [String] |
PUT /api/auth |
Edit the user information. | name: [String], nickname: [String], email: [String] |
PUT /api/auth |
Edit the user password. | current_password: [String], password: [String], password_confirmation: [String] |
POST /api/auth |
Forgot the user password. | email: [String] |
DELETE /api/auth |
Remove the user. | |
POST /api/auth/sign_in |
Login user's session. | email: [String], password: [String] |
DELETE /api/auth/sign_out |
Logout user's session. | |
GET /api/contacts |
Get all contacts. | |
GET /api/contacts/:id |
Get details of a single contact. | |
POST /api/contacts |
Create a new contact. | name: [String], email: [String], kind: [Integer] |
PUT /api/contacts/:id |
Edit the details of an existing contact. | name: [String], email: [String], kind: [Integer] |
DELETE /api/contacts/:id |
Remove the contact. | |
GET /api/contacts/:contact_id/phones |
Get all contact phones. | |
POST /api/contacts/:contact_id/phone |
Add a new phone for the contact. | number: [Integer] |
PUT /api/contacts/:contact_id/phone |
Edit the contact phone. | number: [Integer] |
DELETE /api/contacts/:contact_id/phone |
Remove the contact phone. | |
GET /api/contacts/:contact_id/address |
Get all contact phones. | |
POST /api/contacts/:contact_id/address |
Create a new address for the contact. | street: [String], city: [String] |
PUT /api/contacts/:contact_id/address |
Edit the contact address. | street: [String], city: [String] |
DELETE /api/contacts/:contact_id/address |
Remove the contact address. |