Api for Restaurant Passport. A web application for finding the best places to eat near you.
-
Users - Get a user with the id. - Get all active restaurants for a user. - Log a user in. - Register a new user. - Update user info.
-
Restaurants - Get a restaurant by id. - Get all restaurants. - Edit restaurant.- Delete restaurant.
GET /users/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | User id. |
Request example:
const request = axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.get('/users/1');
User Data
{
"id": 1,
"created_at": "2019-05-20T04:20:43.000Z",
"updated_at": "2019-05-21T02:35:03.374Z",
"name": "Fancy Schaden",
"email": "Ashtyn7@yahoo.com",
"address": "99550 Marquardt Hill",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
GET /users/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | User id. |
Request example:
const request = axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.get('/users/1');
Get Success
{
"id": 1,
"created_at": "2019-05-20T04:20:43.000Z",
"updated_at": "2019-05-21T02:35:03.374Z",
"name": "Fancy Schaden",
"email": "Ashtyn7@yahoo.com",
"address": "99550 Marquardt Hill",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025,
"restaurants": [
{
"restaurant_id": 1,
"name": "Bartoletti and Sons",
"address": "106 Jean Unions",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025,
"visited": 0
},
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
POST /users/login
| Name | Type | Description |
|---|---|---|
| String | Users email address |
|
| password | String | Users password |
Login example:
axios.post('/users/login', {
email:"Ashtyn7@yahoo.com",
password: "password"
});
Login Success
{
"message": "Welcome Ray Doe!",
"email": "ray_doe@gmail.com",
"name": "Ray Doe",
"id": 14,
"status": 200,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTQsImNyZWF0ZWRfYXQiOiIyMDE5LTA1LTIxVDAyOjU5OjAwLjY2NFoiLCJ1cGRh"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
POST /users/register
| Name | Type | Description |
|---|---|---|
| String | Users email |
|
| password | String | Users password |
| address | String | Users address |
| city | String | Users city |
| state | String | Users state |
| zipCode | Number | Users zip code |
| created_at | String | optional Timestamp the user was created |
| updated_at | String | optional Timestamp the user was last updated. |
Register example:
axios.post('/users/register', {
name: "George Doe",
email: "george_doe@gmail.com",
password: "password",
address: "1234 Street",
city: "Manhattan",
state: "New York",
zipCode: 123490
});
Register Success
{
"user": {
"id": 15,
"created_at": "2019-05-21T13:03:23.757Z",
"updated_at": "2019-05-21T13:03:23.757Z",
"name": "George Doe",
"email": "george_doe@gmail.com",
"password": "$2b$10$f3s72tsaTIkhbVh2IleeyOWCGRRlQVWWGaVfAAZQhur2lNCjx0fZG",
"address": "1234 Street",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUsImNyZWF0ZWRfYXQiOiIyMDE5LTA1LTIxVDEzOjAzOjIzLjc1N1oiLCJ1cGRhdGVkX2F0Ijoi"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
PUT /users/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | User id. |
| String | optional Users email |
|
| password | String | optional Users password |
| name | String | optional Users name |
| address | String | optional Users address |
| city | String | optional Users city |
| state | String | optional Users state |
| zipCode | Number | optional Users zip code |
Request example:
const request = axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.put('/users/11');
Update Success
{
"id": 11
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
Get /restaurants/:id
| Name | Type | Description |
|---|---|---|
| id | Number | Restaurants id |
Register example:
axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.get('/restaurants/1');
Get by ID Success
{
"id": 1,
"name": "Schmidt, Kirlin and Ledner",
"address": "315 Keeling Brooks",
"image_url": "http://lorempixel.com/640/480/food",
"description": "Pariatur sunt voluptatem. Et architecto eos. Qui nulla perspiciatis dignissimos incidunt.",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025,
"visited": 0
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
Get /restaurants
Register example:
axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.get('/restaurants');
Get Success
{
"id": 1,
"name": "Schmidt, Kirlin and Ledner",
"address": "315 Keeling Brooks",
"image_url": "http://lorempixel.com/640/480/food",
"description": "Pariatur sunt voluptatem. Et architecto eos. Qui nulla perspiciatis dignissimos incidunt.",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025,
"visited": 0
},
{
"id": 2,
"name": "Hilpert, Rolfson and Klein",
"address": "671 Labadie Radial",
"image_url": "http://lorempixel.com/640/480/food",
"description": "Est modi rerum. Ea eum vel. Maxime velit est iure autem enim est veritatis dolor.",
"city": "Manhattan",
"state": "New York",
"zipCode": 14025,
"visited": 0
},
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
PUT /restaurants/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | Restaurants id. |
| name | String | optional Restaurants name |
| address | String | optional Restaurants address |
| city | String | optional Restaurants city |
| state | String | optional Restaurants state |
| zipCode | Number | optional Restaurants zip code |
Request example:
const request = axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.put('/restaurants/11');
Update Success
{
"id": 11
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
Delete /restaurants/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | Restaurants id. |
Register example:
axios.create({
baseURL: 'http://localhost:4000',
headers: {
authorization: "userTokenGoesHere"
}
});
request.delete('/restaurants/11');
Get Success
{
"status": 204
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}