This is the backend for a contacts app where each user can have its own list of contacts. The app handles user authentication and stores the data to be persistent in a database.
- Ruby on Rails
- PostgreSQL
- JWT for user authentication
- RSpec for testing
https://contacts-ror-app.herokuapp.com/api/v1
First, clone the project and install the project dependencies, to do so run:
bundle install
Create a .env
file and add a POSTGRESQL_DATABASE_USERNAME
and POSTGRESQL_DATABASE_PASSWORD
variable with the username and password of the PostreSQL database. Should be something like:
POSTGRESQL_DATABASE_USERNAME=YOUR_PASSWORD
POSTGRESQL_DATABASE_PASSWORD=YOUR_USERNAME
Finally, start the server with:
rails s
To run the tests:
bundle exec rspec
- Body
{
"email": "[email protected]",
"password": "test123"
}
- Success Response
{
"id": 1,
"email": "[email protected]",
"created_at": "2021-10-03T16:20:53.280Z",
"updated_at": "2021-10-03T16:20:53.280Z"
}
- Error Response
400 BAD REQUEST
-
Parameters
email
andpassword
-
Success Response
{
"user": {
"id": 1,
"email": "[email protected]",
"created_at": "2021-10-03T15:57:38.242Z",
"updated_at": "2021-10-03T15:57:38.242Z"
},
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyMH0.UX8SaCzkRQsZfJutKKujynJ5YCev8taMrIxGKjg0wQ0"
}
- Error Response
400 BAD REQUEST
- Success Response
[
{
"id": 1,
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777888,
"user_id": 1,
"created_at": "2021-10-03T19:39:40.372Z",
"updated_at": "2021-10-03T19:39:40.372Z"
}
]
- Error Response
401 UNAUTHORIZED
- Body
{
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777888
}
- Success Response
{
"id": 1,
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777888,
"user_id": 1,
"created_at": "2021-10-03T19:52:04.632Z",
"updated_at": "2021-10-03T19:52:04.632Z"
}
- Error Response
400 BAD REQUEST
401 UNAUTHORIZED
403 FORBIDDEN
- Success Response
{
"id": {id},
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777888,
"user_id": 1,
"created_at": "2021-10-03T19:39:40.372Z",
"updated_at": "2021-10-03T19:47:18.672Z"
}
- Error Response
404 NOT FOUND
401 UNAUTHORIZED
403 FORBIDDEN
- Body
{
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777111
}
- Success Response
{
"id": {id},
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777111,
"user_id": 1,
"created_at": "2021-10-03T19:39:40.372Z",
"updated_at": "2021-10-03T19:47:18.672Z"
}
- Error Response
400 BAD REQUEST
401 UNAUTHORIZED
403 FORBIDDEN
-
Success Response
200 OK
-
Error Response
404 NOT FOUND
401 UNAUTHORIZED
403 FORBIDDEN
- Success Response
[
{
"id": 1,
"first_name": "Carlos",
"last_name": "Bertomeu",
"email": "[email protected]",
"phone_number": 666777222,
"contact_id": {id},
"created_at": "2021-10-03T19:39:40.408Z",
"updated_at": "2021-10-03T19:39:40.408Z",
"state": "created",
"user_id": 1
}
]
- Error Response
404 NOT FOUND
401 UNAUTHORIZED
403 FORBIDDEN