Skip to content

build-farm-fresh-produce/back-end

Repository files navigation

Users Schema

field data type metadata
id unsigned integer primary key, auto-increments, generated by database
password string required
is_farmer string required

Farms Schema

field data type metadata
id unsigned integer primary key, auto-increments, generated by database
farm_name string required
owner_id string foreign key referencing user.id, required
address string required
city string required
state string required
zipcode string required
phone_numer string required
email string required

Products Schema

field data type metadata
id unsigned integer primary key, auto-increments, generated by database
farm_id string foreign key referencing user.id, required
product_name string required
description string required
image_url string required
price float required
unit string required

Orders Schema

field data type metadata
id unsigned integer primary key, auto-increments, generated by database
user_id string foreign key referencing user.id, required
product_id integer required
quantity float required
total float required

inventory Schema

field data type metadata
id unsigned integer primary key, auto-increments, generated by database
farm_id integer foreign key referencing user.id, required
product_id integer required
quantity_in_stock integer required

API

The following endpoints are available :

https://farm-fresh-produce-api.herokuapp.com/ - welcome message

POST request: https://farm-fresh-produce-api.herokuapp.com/api/auth/login - Login - expects JSON Body {"username", "password"} / Returns JSON{message, userId, token}

POST request: https://farm-fresh-produce-api.herokuapp.com/api/auth/register - Add New User -expects JSON Body {"username", "password"} / Returns JSON{id, username}

GET request: https://farm-fresh-produce-api.herokuapp.com/api/farms - returns array of farm objects; ea. object being farm name, address, etc

POST request : https://farm-fresh-produce-api.herokuapp.com/api/farms - Add a Farm - expects JSON Body {"farm_name", "owner_id", "address", "city", "state", "zipcode", "phone_number", "email"}

GET request: https://farm-fresh-produce-api.herokuapp.com/api/products - returns an array of all products in the db

GET request: https://farm-fresh-produce-api.herokuapp.com/api/farms/:id - returns specific product according to {id} passed in URL

POST request: https://farm-fresh-produce-api.herokuapp.com/api/products - Add a product - expects JSON Body {"farm_id", "product_name", "description", "image_url", "price", "unit"}

GET request: https://farm-fresh-produce-api.herokuapp.com/api/products/:id - returns an inventory product object

PUT request: https://farm-fresh-produce-api.herokuapp.com/api/products/:id - Edits a product - expects JSON Body {"farm_id", "product_name", "description", "image_url", "price", "unit"}

GET request: https://farm-fresh-produce-api.herokuapp.com/api/inventory - returns an array of all products in inventory

POST request: https://farm-fresh-produce-api.herokuapp.com/api/inventory - Adds an inventory entry - expects JSON Body {"farm_id", "product_id", "quantity_in_stock"}

PUT request: https://farm-fresh-produce-api.herokuapp.com/api/inventory/:id - Edits an inventory entry according to id - expects JSON Body {"farm_id", "product_id", "quantity_in_stock"}

DELETE request: https://farm-fresh-produce-api.herokuapp.com/api/inventory/:id - Deletes an inventory entry according to id

DELETE request: https://farm-fresh-produce-api.herokuapp.com/api/products/:id - Deletes a product entry according to id

DELETE request: https://farm-fresh-produce-api.herokuapp.com/api/farms/:id - Deletes a farm entry according to id

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •