Skip to content

restaurant123/BE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restaurant Passport v1.0.0

Api for Restaurant Passport. A web application for finding the best places to eat near you.

Users

Get a user with the id.

GET /users/:id

Headers

Name Type Description
authorization String

User auth token.

Parameters

Name Type Description
id Number

User id.

Examples

Request example:

const request = axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.get('/users/1');

Success Response

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 Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Get all active restaurants for a user.

GET /users/:id

Headers

Name Type Description
authorization String

User auth token.

Parameters

Name Type Description
id Number

User id.

Examples

Request example:

const request = axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.get('/users/1');

Success Response

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 Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Log a user in.

POST /users/login

Parameters

Name Type Description
email String

Users email address

password String

Users password

Examples

Login example:

axios.post('/users/login', {
    email:"Ashtyn7@yahoo.com",
    password: "password"
});

Success Response

Login Success


 {
  "message": "Welcome Ray Doe!",
  "email": "ray_doe@gmail.com",
  "name": "Ray Doe",
  "id": 14,
  "status": 200,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTQsImNyZWF0ZWRfYXQiOiIyMDE5LTA1LTIxVDAyOjU5OjAwLjY2NFoiLCJ1cGRh"
}

Error Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Register a new user.

POST /users/register

Parameters

Name Type Description
email 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.

Examples

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
});

Success Response

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 Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Update user info.

PUT /users/:id

Headers

Name Type Description
authorization String

User auth token.

Parameters

Name Type Description
id Number

User id.

email 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

Examples

Request example:

const request = axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.put('/users/11');

Success Response

Update Success


 {
    "id": 11
}

Error Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Restaurants

Get a restaurant by id.

Get /restaurants/:id

Parameters

Name Type Description
id Number

Restaurants id

Examples

Register example:

axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.get('/restaurants/1');

Success Response

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 Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Get all restaurants.

Get /restaurants

Examples

Register example:

axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.get('/restaurants');

Success Response

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 Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Edit restaurant.

PUT /restaurants/:id

Headers

Name Type Description
authorization String

User auth token.

Parameters

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

Examples

Request example:

const request = axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.put('/restaurants/11');

Success Response

Update Success


 {
    "id": 11
}

Error Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

Delete restaurant

Delete /restaurants/:id

Headers

Name Type Description
authorization String

User auth token.

Parameters

Name Type Description
id Number

Restaurants id.

Examples

Register example:

axios.create({
    baseURL: 'http://localhost:4000',
        headers: {
            authorization: "userTokenGoesHere"
        }
});
request.delete('/restaurants/11');

Success Response

Get Success

 {
    "status": 204
  }

Error Response

Error Example:

ERROR XXX
{
    "status": xxx,
    "message": "Some Error Message"
}

About

Backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •