Permalink
Browse files

created hbs files, started working on shop.js

  • Loading branch information...
mekaala committed Feb 13, 2020
0 parents commit dd066c89236d6ddbae30068a4c5cea9504b09e9a
Showing 702 changed files with 137,400 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('/', (req, res) => {
const allShops = shopsApi.index();
res.render('shops/shops', {shops: allShops});
})

shopRouter.get('/new', function(req, res) {
res.send(shopsApi.createShop());
})

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

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

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

shopRouter.delete('/:index', 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="/<TODO: models url here (e.g: /accounts)>">

<!--
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 dd066c8

Please sign in to comment.