Skip to content

opensource-table/reservations

Repository files navigation

BOOKINGS

A user can search for a restaurant based on location, cuisine, or restaurant’s name and visit the restaurant’s page to get an overview of what the restaurant has to offer like photos of their dishes, their menu options, customers’ reviews, and be able to make a reservation.

Related Projects

Table of Contents

  1. Requirements
  2. Development
  3. Usage
  4. CrudOperations

Requirements

An nvmrc file is included if using nvm.

  • Node 6.13.0
  • etc

Development

Seeding Database

  • Before seeding, make sure to npm install
  • Log into mySQL from terminal: mySQL -u root -p
  • Enter password if set up with one
  • If 'reservations' database exists in mySQL: drop database reservations;
  • Create database in mySQL: create database reservations;
  • Select database: use reservations;
  • Go to db/db.js to change your user and password on line 4
  • Run script: npm run seed
  • To check 'reservations' database: select * from restaurants;

Usage

From within the root directory:

npm install
npm run build
npm start
  • In a broswer, go to: localhost:3020

Crud

Method URL Operation
GET '/:id/bookings' Retrieves the data
POST '/bookings'
PUT '/:id/bookings'
DELETE '/:id/bookings'

Create a new restaurant with its availability and data

URL

/bookings

Method

POST

URL Parameters:

none

Data Parameters:

POST will have a JSON.stringified object containing the info needed to book a restaurant which includes: the restaurant id, the reservation date, the time slot, and the party size.

Success Response:

Code: 201 Created

Error Response:

Code: 500 INTERNAL SERVER ERROR Content: { 'Could not create reservation' }

Sample Call:

$.ajax({ url: "/:id/bookings", dataType: "json", type : "POST", success : (err, results) => { if (err) { console.log(err); } else { this.setState({ bookings: res.data.booked, resName: res.data.name, allData: res.data, }); } } });

Receive one restaurants availability and data

URL

/:id/bookings

Method

GET

URL Parameters:

id=[interger]

Data Parameters:

GET will have an id on its body payload

Success Response:

Code: 200 OK

Error Response:

Code: 404 NOT FOUND Content: { 'unable to retrieve from db: ', err) }

Sample Call:

$.ajax({ url: "/:id/bookings", dataType: "json", type : "GET", success : (err, results) => { if (err) { console.log(err); } else { this.setState({ bookings: res.data.booked, resName: res.data.name, allData: res.data, }); } } });

Update one restaurants availability and data

URL

/:id/bookings

Method

PUT

URL Parameters:

id=[interger]

Data Parameters:

PUT will have an id on its body payload and a JSON.stringified object of the info which needs to be updated which could include any of: the restaurant id, the reservation date, the time slot, and the party size

Success Response:

Code: 202 ACCEPTED

Error Response:

Code: 500 INTERNAL SERVER ERROR Content: { 'Could not update reservation' }

Sample Call:

$.ajax({ url: "/:id/bookings", dataType: "json", data: {containg properties and values that need to be updated}, contentType: json, type : "PUT", success : (err, results) => { if (err) { console.log(err); } else { this.setState({ bookings: res.data.booked, resName: res.data.name, allData: res.data, }); } } });

Delete one restaurants availability and data

URL

/:id/bookings

Method

DELETE

URL Parameters:

id=[interger]

Data Parameters:

DELETE will have an id on its body payload

Success Response:

Code: 202 ACCEPTED

Error Response:

Code: 500 INTERNAL SERVER ERROR Content: { 'Could not delete reservation' }

Sample Call:

$.ajax({ url: "/:id/bookings", dataType: "json", type : "DELETE", success : (err, results) => { if (err) { console.log(err); } else { this.setState({ bookings: res.data.booked, resName: res.data.name, allData: res.data, }); } } });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •