Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Latest commit

 

History

History
290 lines (182 loc) · 7.74 KB

README.md

File metadata and controls

290 lines (182 loc) · 7.74 KB

I'll Serve Soup 2

Server and Database

To start the server if running locally:

First, install all dependencies using yarn or npm before moving on. I recommend npm because yarn couldn't find bcryptjs when I was setting this up.

Run npm run start OR yarn start to start. By default the server runs on port 5000 if it is not found at https://ill-serve-soup2-db.herokuapp.com/

Table of Contents

Database Tables Inventory | Users | Locations |

CRUD Endpoints Inventory | Users | User Accounts | Locations |

NOTE: Do not include the id number in any PUT or POST requests. The system autogenerates it.

NOTE #2: You must put quotation marks around the key names in your objects, otherwise you will receive an error. { "username" : "abc123" }, not { username : "abc123" }


Database Schema

Tables

Column names are italicized and bolded

Inventory

Used for managing total inventory and individual items. Able to Add items, remove items, update items AND get a list of the total inventory

  • Has an auto-incrementing unique id number (you don't need to add this)

  • An item name is required and must be unique, with a max length of 255 characters

  • A quantity is optional. If you don't add a quantity, it will default to 0.

  • The units are also optional. This would be useful for entering units of measure for ingredients. Can be anything and is made to be flexible for a soup kitchen that probably does not track the inventory down to the ounce. (example: "lbs" or "bags" for dry goods, "cans" for canned goods)

example:

id name quantity units
1 Chicken Soup 25 cans

Users

Used to manage list of users and individual users

  • Has an autoincrementing, unique id number (you don't need to add this)

  • A user username is required and must be unique, max length 255 characters

  • A user password is required, max length 255 characters.

  • A user name , max length 255 characters

  • A user role is required, max length 128 characters (Though this will depend on whoever creates the registration form, here are some examples: "admin", "cook", "assistant", "manager", "volunteer", etc. )

  • A user email , max length 255 characters

  • A user phone , max length 128 characters

example:

id username password name role email phone
3 jsmith99 password Joe Smith volunteer [email protected] 123-456-7890

Locations

Used to manage list of locations and individual locations

  • Has an autoincrementing, unique ID number

  • A name is required and must be unique, max length 255 characters

  • A streetAddress, max length 255 characters

  • A city , max length 255 characters

  • A state, max length 128 characters

  • An email , max length 255 characters

  • A phone , max length 128 characters

example:

id name streetAddress city state zipCode email phone
3 Downtown 123 Main St Townville Oregon 12345 [email protected] 123-456-7890

Endpoints

Inventory

/api/inventory

GET

Returns a JSON object with the entire inventory. User must be logged in to access.

POST

The request body must include a unique name, and can optionally include quantity and units. User must be logged in to access. Returns a success message and the id number of the new item.

{
	name:  "Tuna - Salad Premix", //required
	quantity:  89,
	units:  "ounces",
},

/api/inventory/{id}

GET

Returns a JSON object with the corresponding item. User must be logged in to access.

PUT

The request body must include information to be updated. User must be logged in to access.

DELETE

Permanently removes the item from the inventory. A confirmation dialog may be a good idea here. User must be logged in to access.


Users

/api/users

GET

Returns a JSON object with the entire users list. User must be logged in to access this.

REACT DEV >> You need to have a way to retrieve the token that is generated.


/api/users/{id}

GET

Returns a JSON object with the corresponding user. User must be logged in to access.

{
    "id": 4,
    "username": "joller3",
    "name": "Jerrie Oller",
    "role": "cook",
    "email": "[email protected]",
    "phone": "529-300-3099"
}

PUT

The request body must include information to be updated. User must be logged in to access.

DELETE

Permanently removes the corresponding user from the database. A confirmation dialog may be a good idea here. User must be logged in to access.


User Accounts

/api/useraccounts/register

POST

The request body must include a unique username and a password. It can optionally include a name, role, email, and phone number. Returns a success message and the id number of the new user.

{
	username:  "jdacthj", //unique, required
	password:  "hvTsxvWsRRl", //required
	name:  "Jaquenette D'Acth",
	role:  "volunteer",
	email:  "[email protected]",
	phone:  "710-804-5935",
}

/api/useraccounts/login

POST

The request body must include a unique username and a password matching what is on the database.

{
	username:  "jdacthj", // required
	password:  "hvTsxvWsRRl", //required
}

REACT DEV >> You need to have a way to store the token that is generated. LocalStorage(setItem) is a simple way


Locations

/api/locations

GET

Returns a JSON object with the entire locations list. User must be logged in to access.

POST

The request body must include a unique name, and can optionally include a streetAddress, a city, state, zipCode, email, and phone. User must be logged in to access.

{
	name:  "Independence", // unique, required
	streetAddress:  "20 Saint Paul Park",
	city:  "Bronx",
	state:  "New York",
	zipCode:  12345,
	email:  bronxsoupkitchen@email.com,
	phone:  "718-395-9875",
},

/api/locations/{id}

GET

Returns a JSON object with the corresponding location. User must be logged in to access.

{
	id:  6,
	name:  "Northview",
	streetAddress:  "7172 Northridge Crossing",
	city:  "Plano",
	state:  "Texas",
	zipCode:  "75074",
	email:  "[email protected]",
	phone:  "972-650-6963",
},

PUT

The request body must include information to be updated. User must be logged in to access.

DELETE

Permanently removes the corresponding location from the database. A confirmation dialog may be a good idea here. User must be logged in to access.


                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
            __.'              ~.   .~              `.__
          .'//        END       \./      OF   THE    \\`.
        .'//                     |           README    \\`.
      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
    .'//.-"                 `-.  |  .-'                 "-.\\`.
  .'//______.============-..   \ | /   ..-============.______\\`.
.'______________________________\|/______________________________`.