Permalink
Browse files

initial

  • Loading branch information...
BellaJCo
BellaJCo committed Feb 13, 2020
0 parents commit fc403c1c9f0358067161d8a54bc7fe6b7f41902e
Showing 701 changed files with 137,406 additions and 0 deletions.
@@ -0,0 +1,73 @@
/* Step 1 import express
*
*/
const express = require('express')


/* Step 2
*
* Import the api files from the models
*
* TODO: change the file path to the models file you'll need to use.
* TODO: rename this from `shopsApi` to something more sensible (e.g:
* `shopsAPI`)
*
* NOTE: You may need to import more than one API to create the
* controller you need.
*
*/
const shopsApi = require('../models/shop.js')

/* Step 3
*
* Create a new router.
*
* the router will "contain" all the request handlers that you define in this file.
* TODO: rename this from shopRouter to something that makes sense. (e.g:
* `shopRouter`)
*/
const shopRouter = express.Router()


/* Step 4
*
*/

shopRouter.get('/', function(req,res) {
res.render(shopsApi.getShops());
})

shopRouter.get('/new', function(req, res) {
res.render(shops:createShop(req.params.index));
})

shopRouter.get('/shops/shop', function(req,res){
res.send(shopsApi.getShop(req.params.index));
})

shopRouter.post('/', function(req,res){
shopsApi.addShop(req.body);
res.status(200).end();
res.redirect('/shops/')
})

shopRouter.put('/:index', function(req,res){
shopsApi.updateShop(req.params.index, req.body);
res.status(200).end();
})

shopRouter.delete('/shops', function(req,res){
shopsApi.deleteShop(req.params.index)
res.status(200).end();
})


/* Step 6
*
* Export the router from the file.
*
*/
module.exports = {
shopRouter
}

@@ -0,0 +1,12 @@
<form method="POST" action="/shops">

<!--
Template for creating input form for a string object key called stringMember
NOTE: for numeric input fields use `type="number"`
--->
<input type="text" value="{{<TODO: model.stringMember (e.g: account.name)}}" placeholder="name" name="<TODO: stringMember (e.g: name)>" />

<input type="checkbox" name="<TODO: model.booleanMember (e.g: account.isActive)" value="true" />

<input type="submit" value="Create Shop" />
</form>
@@ -0,0 +1,51 @@
/*
* Place all functions, classes, and/or DB schemas here for a single
* model.
*/
global.shops = [];

/*
* TODO: delete this it's just a sample
*
*/
function createShop() {
return {
name: "",
employees: 0,
currentlyOpen: false
};
}

function getShops() {
return global.shops;
}

function getShop(i) {
return global.shops[i];
}

function addShop(newShop) {
global.shops.push(newShop);
}

function updateShop(i, shop) {
global.shops[i] = shop;
}

function deleteShop(i) {
global.shops.splice(i, 1);
}

/* Step 1
*
* TODO: export all functions from this file by adding their names as keys to this
* object
*/
module.exports = {
addShop,
createShop,
deleteShop,
getShop,
getShops,
updateShop,
};

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit fc403c1

Please sign in to comment.