No description, website, or topics provided.
Clone or download
Latest commit 50c1aa5 Feb 14, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
controllers homework Feb 14, 2020
models homework Feb 14, 2020
views homework Feb 14, 2020
.gitignore homework Feb 14, 2020
package-lock.json homework Feb 14, 2020
package.json homework Feb 14, 2020
readme.md homework Feb 14, 2020
server.js homework Feb 14, 2020

readme.md

express-intro-exercise

Objective

  • Create an HTTP web wrapper around a set of model code.

Setup

Follow the instructions for setting up a new project from the mehn-template-project readme.

NOTE: be sure that server.js uses the express.json() middleware and not the express.urlencoded() middleware.

Create API

  1. Copy the models/template.js to models/shops.js
  2. In models/shops.js create a set of functions to perform the following:
function name parameters return
getShops n/a list of shops
getShop index single shop
createShop n/a new shop
addShop newShop n/a
deleteShop index n/a
updateShop index, shop n/a

Each coffee shop should have the following schema:

  • name (string)
  • employees (number)
  • currentlyOpen (boolean)

Create Web Server

  1. Copy the controllers/template.js file to controllers/shops.js
  2. In controllers/shops.js create as set of HTTP request handlers to do the following:
path Method model function to call
/shops GET getShops
/shops/:index GET getShop
/shops/new GET createShop
/shops POST addShop
/shops/:index DELETE deleteShop
/shops/:index PUT updateShop

Strech Goals

  1. Add some more methods to your model that modify the data inside of the coffee shop (such as adding a menu item or changing the name) and write an HTTP request handler around that.
  2. create an other model called employees. Create a controller for these employees
  3. add a key to the employees model called shopIndex. Add a method that will get all employees given the value of shopIndex.
  4. Write an controller function that uses the function from the previous step.