diff --git a/js/controllers/pagesCtrlFile.js b/js/controllers/pagesCtrlFile.js new file mode 100644 index 0000000000000000000000000000000000000000..ffd0e319451c3fa875017b988a077ffb979ec699 --- /dev/null +++ b/js/controllers/pagesCtrlFile.js @@ -0,0 +1,31 @@ +exports.hCtrlFunction = (req, res) => { + res.render('index'); +} + +exports.cartCtrlFunction = (req, res) => { + res.render('cart'); +} + +exports.kidsSCtrlFunction = (req, res) => { + res.render('kids-shoes'); +} + +exports.kidsCtrlFunction = (req, res) => { + res.render('kids'); +} + +exports.menSCtrlFunction = (req, res) => { + res.render('men-shoes'); +} + +exports.menCtrlFunction = (req, res) => { + res.render('men'); +} + +exports.womenSCtrlFunction = (req, res) => { + res.render('women-shoes'); +} + +exports.womenCtrlFunction = (req, res) => { + res.render('women'); +} \ No newline at end of file diff --git a/js/routes/pages.js b/js/routes/pages.js new file mode 100644 index 0000000000000000000000000000000000000000..8945d3b3b059decf79c77e650a35f8cabf9a1809 --- /dev/null +++ b/js/routes/pages.js @@ -0,0 +1,16 @@ +const express = require('express'); +//const { modules } = require('node:module'); +const { hCtrlFunction, cartCtrlFunction, kidsSCtrlFunction, kidsCtrlFunction, menSCtrlFunction, menCtrlFunction, womenSCtrlFunction, womenCtrlFunction } = require('../controllers/pagesCtrlFile'); + +const router = express.Router(); + +router.get('/', hCtrlFunction); +router.get('/cart', cartCtrlFunction); +router.get('/kids-shoes', kidsSCtrlFunction); +router.get('/kids', kidsCtrlFunction); +router.get('/men-shoes', menSCtrlFunction); +router.get('/men', menCtrlFunction); +router.get('/women-shoes', womenSCtrlFunction); +router.get('/women', womenCtrlFunction); + +module.exports = router; \ No newline at end of file diff --git a/js/server.js b/js/server.js index 7621506ef844e864c2488e18c5d9539ef805b7d5..adb4b9604b8f0e4cb32945fab469fd5b0a5c37b8 100644 --- a/js/server.js +++ b/js/server.js @@ -7,37 +7,8 @@ console.log(publicDirectory); */ app.use(express.static(publicDirectory)); app.set('view engine', 'hbs'); -app.get("/", (req, res) => { - res.render('index'); -}) +app.use('/', require('./routes/pages')); -app.get("/men", (req, res) => { - res.render('men'); -}) - -app.get("/women", (req, res) => { - res.render('women'); -}) - -app.get("/kids", (req, res) => { - res.render('kids'); -}) - -app.get("/men-shoes", (req, res) => { - res.render('men-shoes'); -}) - -app.get("/women-shoes", (req, res) => { - res.render('women-shoes'); -}) - -app.get("/kids-shoes", (req, res) => { - res.render('kids-shoes'); -}) - -app.get("/cart", (req, res) => { - res.render('cart'); -}) app.listen(5000, () => { console.log("Server is listening on port 5000"); }) \ No newline at end of file diff --git a/products.js b/products.js new file mode 100644 index 0000000000000000000000000000000000000000..503c1ef55fdbcd781959c29122aca95ca8bb94d2 --- /dev/null +++ b/products.js @@ -0,0 +1,86 @@ +exports.productList = [ + { + name: 'Blue Shirt', + description: 'This is a Blue Shirt', + tag: 'BlueShirt', + price: 29.99, + inCart: 0 + }, + { + name: 'Black Shirt', + description: 'This is a Black Shirt', + tag: 'BlackShirt', + price: 23.99, + inCart: 0 + }, + { + name: 'White Shirt', + description: 'This is a White Shirt', + tag: 'WhiteShirt', + price: 89.99, + inCart: 0 + }, + { + name: 'Denim jeans', + description: 'This is a Denim jeans', + tag: 'DenimJeans', + price: 150.00, + inCart: 0 + }, + { + name: 'Light blue jeans', + description: 'This is a Light blue jeans', + tag: 'LightBlue', + price: 50.00, + inCart: 0 + }, + { + name: 'Cotton jeans', + description: 'This is a Cotton jeans', + tag: 'Cottonjeans', + price: 200.00, + inCart: 0 + }, + { + name: 'Blue blouse', + description: 'This is a Blue blouse', + tag: 'Blueblouse', + price: 59.99, + inCart: 0 + }, + { + name: 'Off White blouse', + description: 'This is an Off White blouse', + tag: 'OffWhiteblouse', + price: 73.99, + inCart: 0 + }, + { + name: 'White blouse', + description: 'This is a White blouse', + tag: 'Whiteblouse', + price: 89.99, + inCart: 0 + }, + { + name: 'Brown trouser', + description: 'This is a Brown trouser', + tag: 'Browntrouser', + price: 140.00, + inCart: 0 + }, + { + name: 'Cream trouser', + description: 'This is a Cream trouser', + tag: 'Creamtrouser', + price: 59.00, + inCart: 0 + }, + { + name: 'Grey trouser', + description: 'This is a Grey trouser', + tag: 'Greytrouser', + price: 201.00, + inCart: 0 + } +] \ No newline at end of file