Giter VIP home page Giter VIP logo

restaurants_reservation_api's Introduction

restaurants_reservation_api

Before you start make sure you have installed:

Before using the api for the first time:

  • Create the .env file
  • Install the dependencies
  • Create the needed tables in your database
  • Insert the timeslots of table reservation to the database
  • Insert the tables of the restaurant to the database

How to create the .env file:

  • Create a new file in the root folder and name it: '.env'
  • Write the environment variables of your environment as the following format
DB_HOST=[your DBMS host address]
DB_PORT=[your DBMS port]
DB_USER=[database username]
DB_NAME=[database name]
DB_PASSWORD=[database password]
SERVER_PORT=[backend server port]

Example:

DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_NAME=postgres
DB_PASSWORD=000000
SERVER_PORT=3000
  • Save the file

How to install the dependencies:

  • Run the following command
npm install

How to create the needed tables in your database:

  • Run the following queries in your RDBMS
CREATE TABLE employees (employee_id serial PRIMARY KEY, employee_number INT UNIQUE NOT NULL,employee_name VARCHAR ( 50 ) NOT NULL, password VARCHAR ( 128 ) NOT NULL);
CREATE TABLE reservation_timeslots (reservation_timeslot_id serial PRIMARY KEY, start_at TIME NOT NULL, end_at TIME NOT NULL);
CREATE TABLE tables (table_id serial PRIMARY KEY, number_of_chairs INT NOT NULL, is_active bool NOT NULL);
CREATE TABLE reservations (reservation_id serial PRIMARY KEY, reservation_timeslot_id INT NOT NULL, table_id INT NOT NULL, reservation_date DATE NOT NULL);

Note: SQL file is included

How to insert the timeslots of table reservation to the database:

  • Run the following query in your RDBMS to insert reservation timeslot
INSERT INTO reservation_timeslots (start_at, end_at) VALUES ([TIME value], [TIME value]);

Example:

INSERT INTO reservation_timeslots (start_at, end_at) VALUES ('12:30', '13:45');

How to insert the tables of the restaurant to the database:

  • Run the following query in your RDBMS to insert reservation timeslot
INSERT INTO tables (number_of_chairs, is_active) VALUES ([INT value], [BOOLEAN value]);

Example:

INSERT INTO tables (number_of_chairs, is_active) VALUES (4, 'true');

API functions

  • /login
  • /signup
  • /check_timeslotes
  • /new_reservation
  • /get_reservation
  • /delete_reservation

/login

  • Function type: post
  • Function parameters: employee_number, password
  • return: token
  • algorithim 1

/signup

  • Function type: post
  • Function parameters: employee_number, employee_number, password
  • return: token
  • algorithim 1 (1)

/check_timeslotes

  • Function type: get
  • Function parameters: token, number_of_chairs
  • return: available reservations data
  • algorithim 1 (3)

/new_reservation

  • Function type: post
  • Function parameters: token, reservation_timeslot_id, table_id
  • return: success / fail
  • algorithim 1 (4)

/get_reservation

  • Function type: get
  • Function parameters: token, page_number (page of results), is_ascending ('true' or 'false')
  • return: a page of reservations data of today that sorted ascending or descending that has up to 10 results, hasNextPage (a bool that showes if their is a next page pf results)
  • algorithim 1

/delete_reservation

  • Function type: delete
  • Function parameters: token, reservation_id
  • return: 'success' / 'no such data reservation'
  • algorithim 1 (5)



restaurants_reservation_api's People

Contributors

haithamswe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.