diff --git a/app.js b/app.js index d6e0739..1d85ffb 100644 --- a/app.js +++ b/app.js @@ -6,6 +6,7 @@ var logger = require('morgan'); var homeRouter = require('./routes/home'); var autenicarRouter = require('./routes/autenticar'); +var produtosRouter = require('./routes/produtos'); var app = express(); @@ -21,6 +22,7 @@ app.use(express.static(path.join(__dirname, 'public'))); app.use('/', homeRouter); app.use('/autenticar', autenicarRouter); +app.use('/produtos', produtosRouter); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/controllers/produtosController.js b/controllers/produtosController.js new file mode 100644 index 0000000..5f4385f --- /dev/null +++ b/controllers/produtosController.js @@ -0,0 +1,14 @@ +const listar = function(req, res){ + res.render('produtos/listar', { + title: "Titulo" + }) +} + +const visualizar = function(req, res){ + const id = req.params.id + res.render('produtos/visualizar', { + titulo: id + }) +} + +module.exports = { listar, visualizar } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 279c6f7..b010e1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,19 +317,21 @@ } }, "node_modules/cookie": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/cookie-parser": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz", - "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==", + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", + "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "license": "MIT", "dependencies": { - "cookie": "0.4.1", + "cookie": "0.7.2", "cookie-signature": "1.0.6" }, "engines": { @@ -442,16 +444,17 @@ } }, "node_modules/express": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", - "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.6.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -483,9 +486,10 @@ } }, "node_modules/express/node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "license": "MIT", "engines": { "node": ">= 0.6" } diff --git a/routes/home.js b/routes/home.js index 1e714bc..14d018b 100644 --- a/routes/home.js +++ b/routes/home.js @@ -1,6 +1,6 @@ var express = require('express'); var router = express.Router(); -const { home } = require('../controllers/homeController') +const { home } = require('../controllers/homeController'); /* GET home page. */ router.get('/', home); diff --git a/routes/produtos.js b/routes/produtos.js new file mode 100644 index 0000000..8e18105 --- /dev/null +++ b/routes/produtos.js @@ -0,0 +1,9 @@ +var express = require('express'); +var router = express.Router(); +const { listar, visualizar } = require('../controllers/produtosController'); + +router.get('/', listar); +router.get('/:id', visualizar); +router.get('/busca', visualizar); + +module.exports = router; diff --git a/views/produtos/listar.ejs b/views/produtos/listar.ejs new file mode 100644 index 0000000..2376573 --- /dev/null +++ b/views/produtos/listar.ejs @@ -0,0 +1,17 @@ + + +
+ + + +