Backend Express Server & SQLite DB for Ride4Life App
HTTP Method: POST
URL: /api/auth/signup
| Name | Type | Required | Description |
|---|---|---|---|
| first_name | String | Yes | User's first name |
| last_name | String | Yes | User's last name |
| String | Yes | User's email | |
| username | String | Yes | User's chosen username |
| password | String | Yes | User's chosen password |
| isDriver | Boolean | Yes | If user is a driver |
| phone_number | String | Yes | User's phone number |
| price | Integer | No | User's price |
{
"first_name": "Stevenva",
"last_name": "Vandenburgva",
"email": "smvav5047@gmail.com",
"username": "test3",
"password": "test3",
"isDriver": "false",
"phone_number": "2156662381",
"price": 2000
}201 (Created)
If successfully signed up, endpoint will return HTTP response with status code and a body with a token and message welcoming the user by their first_name
401 (Bad Request)
If required information is missing, the endpoint will return an HTTP response with a status code of 401
500 (Internal Server Error)
If there was a server error registering the user, a response with status code 500 will be returned.
HTTP Method: POST URL: /api/auth/login
| Name | Type | Required | Description |
|---|---|---|---|
| username | String | Yes | User's username |
| password | String | Yes | User's password |
{
"username": "test3",
"password": "test3"
}200 (OK)
If successfully logged in, endpoint will return HTTP response with status code and a body with a token and message welcoming the user by their first_name, as well as a userID
401 (Unauthorized)
If username is not found or password is incorrect, status 401 will be returned
500 (Internal Server Error)
If there was a server error logging the user in, a response with status code 500 will be returned.
HTTP Method: POST URL: /api/ride/request
| Name | Type | Required | Description |
|---|---|---|---|
| username | String | Yes | User's username |
| latitude | String | Yes | User's current latitude |
| longitude | String | Yes | User's current longitude |
{
"username": "JohnD",
"latitude": "8.2414",
"longitude": "1.3231"
}200 (OK)
If successfully logged in, endpoint will return HTTP response with status code and a body with the ETA until the driver return
{
"ETA": "3 hours 53 mins",
"username": "test
}401 (Unauthorized)
If user is not authorized to request a ride, status 401 will be returned
500 (Internal Server Error)
If there was a server error, a response with status code 500 will be returned.
HTTP Method: Get URL: /api/profile/:userid
N/A
/api/profile/:userid (userid should be the users id that should be retrieved)
/api/profile/1
Would return
{
"id": 1,
"first_name": "John",
"last_name": "Doe",
"email": "John.Doe@gmail.com",
"username": "JohnD",
"password": "$2a$13$9c5WA9NqPpQeyzgLbvvXO.XvC3mWJ8P24fFedJbnPMFJdhesQahU2",
"isDriver": "false",
"phone_number": "4042262159",
"price": null
}200 (OK)
Endpoint will return HTTP response with status code and a body with the users information
404 (Does Not Exist)
If userid is not found , status 404 will be returned
500 (Internal Server Error)
If there was a server error, a response with status code 500 will be returned.
HTTP Method: Put URL: /api/profile/:userid
| Name | Type | Required | Description |
|---|---|---|---|
| first_name | String | No | User's first name |
| last_name | String | No | User's last name |
| String | No | User's email | |
| username | String | No | User's chosen username |
| password | String | No | User's chosen password |
| isDriver | Boolean | No | If user is a driver |
| phone_number | String | No | User's phone number |
| price | Integer | No | User's price |
/api/profile/:userid (userid should be the users id that should be retrieved)
{
"first_name": "Stevenva",
"last_name": "Vandenburgva",
"email": "smvav5047@gmail.com",
"username": "test3",
"password": "test3",
"isDriver": "false",
"phone_number": "2156662381",
"price": 2000
}200 (OK)
Endpoint will return HTTP response with status code and a body with the updated users information
404 (Does Not Exist)
If userid is not found , status 404 will be returned
500 (Internal Server Error)
If there was a server error, a response with status code 500 will be returned.
HTTP Method: Delete URL: /api/profile/:userid
N/A
/api/profile/:userid (userid should be the users id that should be retrieved)
N/A
200 (OK)
Endpoint will return HTTP response with status code and a message saying user was deleted
404 (Does Not Exist)
If userid is not found , status 404 will be returned
500 (Internal Server Error)
If there was a server error, a response with status code 500 will be returned.
HTTP Method: Get URL: /api/profile/:userid/review
N/A
/api/profile/:userid (userid should be the users id that should be retrieved)
If we look at the reviews
[
{
"id": 1,
"rider_id": 2,
"driver_id": 7,
"review": "The Worst",
"rating": 1
},
{
"id": 2,
"rider_id": 3,
"driver_id": 7,
"review": "Meh",
"rating": 3
},
{
"id": 3,
"rider_id": 4,
"driver_id": 7,
"review": "So Enlightening",
"rating": 4
},
{
"id": 4,
"rider_id": 6,
"driver_id": 7,
"review": " Best Ride ever",
"rating": 5
}
]200 (OK)
Endpoint will return HTTP response with status code and an array of review objects
404 (Does Not Exist)
If driverid is not found , status 404 will be returned
500 (Internal Server Error)
If there was a server error, a response with status code 500 will be returned.
HTTP Method: POST
URL: /api/profile/:driverid/reviews
| Name | Type | Required | Description |
|---|---|---|---|
| rider_id | Integer | Yes | Rider's id |
| review | String | No | Review for Ride |
| rating | Integer | Yes | Rating for Ride |
Must send Driver ID through URL /api/profile/:driverid/reviews
{
"rider_id": 6,
"review": " Best Ride ever",
"rating": 4
}201 (Created)
If successfully create, endpoint will return HTTP response with status code and a message thanking user for review
401 (Bad Request)
If required information is missing, the endpoint will return an HTTP response with a status code of 401
500 (Internal Server Error)
If there was a server error registering the user, a response with status code 500 will be returned.
HTTP Method: DELETE
URL: /api/profile/:driverid/reviews/:reviewid
N/A
Must send Driver ID through URL /api/profile/:driverid/reviews/:reviewid
https://ride-4-life.herokuapp.com/api/profile/7/reviews/4
200 (Deleted)
If review exists, endpoint will return HTTP response with status code and a message notifying user that review was deleted
401 (Bad Request)
If required information is missing, the endpoint will return an HTTP response with a status code of 401
500 (Internal Server Error)
If there was a server error registering the user, a response with status code 500 will be returned.
HTTP Method: PUT
URL: /api/profile/:driverid/reviews/:reviewid
| Name | Type | Required | Description |
|---|---|---|---|
| rider_id | Integer | Yes | Rider's id |
| review | String | No | Review for Ride |
| rating | Integer | Yes | Rating for Ride |
Must send Driver ID through URL https://ride-4-life.herokuapp.com/api/profile/7/reviews/4
{
"rider_id": 6,
"review": " Best Ride ever",
"rating": 4
}204 (Updated)
If successfully updated, endpoint will return HTTP response with status code and a message notifying user that review was updated
401 (Bad Request)
If required information is missing, the endpoint will return an HTTP response with a status code of 401
500 (Internal Server Error)
If there was a server error registering the user, a response with status code 500 will be returned.