From 24826529dbf515621ef1c1931649b2d3a2089c5a Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Wed, 17 Apr 2019 15:32:52 +0100 Subject: [PATCH 1/8] basic route setup --- routes/index.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/routes/index.js b/routes/index.js index 3c20861..413f979 100644 --- a/routes/index.js +++ b/routes/index.js @@ -8,3 +8,42 @@ var Test = require('../controllers/test'); router.get('/', Test.first); module.exports = router; + + +// Updated Router here +/* GET home page. */ +//router.get("/", Home.index); +router.get("/", function(req, res, next) { + JobModel.find(function(err, jobs) { + res.render("index", { title: "Remote Job Alert", contents: jobs }); + }); +}); + + +// GET About us page +router.get("/about", Home.aboutUs); + +//Admin Page +router.get('/admin', Home.admin); + +router.post('/admin', function(req, res, next){ + if (req.body.username && req.body.password) { + Admin.authenticate(req.body.username, req.body.password, function (error, admin) { + if (error || !admin) { + var err = new Error('Wrong username or password.'); + err.status = 401; + return next(err); + } else { + req.session.adminId = admin._id; + return res.redirect('/managefees'); + } + }); +} +}); + + +// GET Contact us page +router.get("/contact", Home.contactUs); + +// GET FAQS us page +router.get("/faqs", Home.faqs); \ No newline at end of file From 2ed5022ab595b60340d3b3118348eba8d0a73ea5 Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Wed, 17 Apr 2019 15:34:46 +0100 Subject: [PATCH 2/8] add more routes --- routes/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index 413f979..b8e3124 100644 --- a/routes/index.js +++ b/routes/index.js @@ -24,7 +24,7 @@ router.get("/", function(req, res, next) { router.get("/about", Home.aboutUs); //Admin Page -router.get('/admin', Home.admin); +router.get('/admin', Home.admin) router.post('/admin', function(req, res, next){ if (req.body.username && req.body.password) { From 32e0ddbbe7942ff65beb288a55b6b47d8cb30b90 Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Wed, 17 Apr 2019 15:35:44 +0100 Subject: [PATCH 3/8] updated router --- routes/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index b8e3124..413f979 100644 --- a/routes/index.js +++ b/routes/index.js @@ -24,7 +24,7 @@ router.get("/", function(req, res, next) { router.get("/about", Home.aboutUs); //Admin Page -router.get('/admin', Home.admin) +router.get('/admin', Home.admin); router.post('/admin', function(req, res, next){ if (req.body.username && req.body.password) { From 70ab06c845fe967abb5c2d6da0423b08b881fe9f Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Wed, 17 Apr 2019 15:38:31 +0100 Subject: [PATCH 4/8] removed admin route --- routes/index.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/routes/index.js b/routes/index.js index 413f979..6a61cbf 100644 --- a/routes/index.js +++ b/routes/index.js @@ -23,24 +23,6 @@ router.get("/", function(req, res, next) { // GET About us page router.get("/about", Home.aboutUs); -//Admin Page -router.get('/admin', Home.admin); - -router.post('/admin', function(req, res, next){ - if (req.body.username && req.body.password) { - Admin.authenticate(req.body.username, req.body.password, function (error, admin) { - if (error || !admin) { - var err = new Error('Wrong username or password.'); - err.status = 401; - return next(err); - } else { - req.session.adminId = admin._id; - return res.redirect('/managefees'); - } - }); -} -}); - // GET Contact us page router.get("/contact", Home.contactUs); From 5fbb3bc8446e82d7b21b7357237e0a56981a32d1 Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Wed, 17 Apr 2019 16:24:50 +0100 Subject: [PATCH 5/8] corrections made to the Route --- routes/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/routes/index.js b/routes/index.js index 6a61cbf..ae7d909 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,9 +1,11 @@ const express = require('express'); const router = express.Router(); +var Home = require("../controllers/home"); // import controllers var Test = require('../controllers/test'); + // welcome page router.get('/', Test.first); @@ -14,8 +16,8 @@ module.exports = router; /* GET home page. */ //router.get("/", Home.index); router.get("/", function(req, res, next) { - JobModel.find(function(err, jobs) { - res.render("index", { title: "Remote Job Alert", contents: jobs }); + Test.find(function(err, fees) { + res.render("index", { title: "School_fees_tracker"}); }); }); From 758e159ad8287cbea1d38086fe316d68a196a46e Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Thu, 18 Apr 2019 14:30:02 +0100 Subject: [PATCH 6/8] made changes to the READme file --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e88b3b0..fea64ac 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ # Getting Started 1. Fork the repository, clone it. -2. cd (change directory) into the project folder i.e remote_job_alert. +2. cd (change directory) into the project folder i.e Fees_tracker 3. Run `npm install` (on your terminal) to install the dependencies. 4. Run `npm start` (on your terminal) to run the project. -5. Go to your browser `localhost:5000` to view the project. +5. Go to your browser `localhost:3030` to view the project. 6. When you make your changes to the repo, push to master and create a pull request, make sure there are no merge conflicts. Fork the repository first and clone it @@ -18,13 +18,13 @@ git clone CLONE_URL Change into cloned repo and install dependencies ``` -npm install +npm install (on your terminal) ``` Start the project ``` -npm start +npm start (on your terminal) ``` Visit `http://localhost:3030` to view the project. @@ -34,3 +34,4 @@ Visit `http://localhost:3030` to view the project. — After making changes to the repo, push to master and create pull request, make sure there are no merge conflicts. — Do not merge pull request, a mentor will. +— You if upon fetch upstream to update and npm start can't run, do npm intall then try again. \ No newline at end of file From 239860b757c7164ae3e698284b9c66c406d91790 Mon Sep 17 00:00:00 2001 From: "lekiagospel@gmail.com" Date: Thu, 18 Apr 2019 14:37:24 +0100 Subject: [PATCH 7/8] Updated the README file --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fea64ac..6e2239d 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,5 @@ Visit `http://localhost:3030` to view the project. — After making changes to the repo, push to master and create pull request, make sure there are no merge conflicts. — Do not merge pull request, a mentor will. -— You if upon fetch upstream to update and npm start can't run, do npm intall then try again. \ No newline at end of file +— +Upon fetch upstream to update your repo and npm start can't run, do npm intall first then try again. \ No newline at end of file From 5704a8c2cc09e2c6920b20e64711d0ecfbd0afea Mon Sep 17 00:00:00 2001 From: Lekia Gospel <47338915+Yigaue@users.noreply.github.com> Date: Thu, 18 Apr 2019 14:41:26 +0100 Subject: [PATCH 8/8] Delete index.js --- routes/index.js | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 routes/index.js diff --git a/routes/index.js b/routes/index.js deleted file mode 100644 index ae7d909..0000000 --- a/routes/index.js +++ /dev/null @@ -1,33 +0,0 @@ -const express = require('express'); -const router = express.Router(); -var Home = require("../controllers/home"); - -// import controllers -var Test = require('../controllers/test'); - - -// welcome page -router.get('/', Test.first); - -module.exports = router; - - -// Updated Router here -/* GET home page. */ -//router.get("/", Home.index); -router.get("/", function(req, res, next) { - Test.find(function(err, fees) { - res.render("index", { title: "School_fees_tracker"}); - }); -}); - - -// GET About us page -router.get("/about", Home.aboutUs); - - -// GET Contact us page -router.get("/contact", Home.contactUs); - -// GET FAQS us page -router.get("/faqs", Home.faqs); \ No newline at end of file