Bladeren bron

Ensure all functions are commented for backend. Fix error.

Lee Morgan 6 jaren geleden
bovenliggende
commit
571dff303a
3 gewijzigde bestanden met toevoegingen van 29 en 12 verwijderingen
  1. 1 1
      controllers/otherData.js
  2. 22 5
      controllers/renderer.js
  3. 6 6
      routes.js

+ 1 - 1
controllers/otherData.js

@@ -1,7 +1,7 @@
 const bcrypt = require("bcryptjs");
 
 const NonPosTransaction = require("../models/nonPosTransaction");
-const Merchant = require("merchant");
+const Merchant = require("../models/merchant");
 
 module.exports = {
     //POST - Update non-pos merchant inventory and create a transaction

+ 22 - 5
controllers/render.js → controllers/renderer.js

@@ -7,7 +7,10 @@ const Transaction = require("../models/transaction");
 const token = "b48068eb-411a-918e-ea64-52007147e42c";
 
 module.exports = {
-    //Public page including login and registration
+    //GET - Shows the public landing page
+    //Returns: 
+    //  Error: a single error message
+    //Renders landingPage
     landingPage: function(req, res){
         let error = {};
         if(req.session.error){
@@ -20,7 +23,10 @@ module.exports = {
         return res.render("landingPage/landing", {error: error});
     },
 
-    //Render the main page for merchants
+    //GET - Displays the main inventory page for merchants
+    //Returns:
+    //  merchant: the logged in merchant
+    //Renders inventoryPage
     displayInventory: function(req, res){
         if(!req.session.user){
             return res.redirect("/");
@@ -88,7 +94,11 @@ module.exports = {
             });
     },
 
-    //Display Merchant Setup Page
+    //GET - Renders the merchant setup page for a clover client
+    //Returns:
+    //  ingredients: all ingredients from database
+    //  recipes: recipes from the users clover account
+    //Renders merchantSetupPage
     merchantSetupClover: function(req, res){
         req.session.posId = "YHVPCQMVB1P81";
         
@@ -109,7 +119,11 @@ module.exports = {
             });
     },
 
-    //Display page to set up merchant with no POS system
+    //GET - Renders the merchant setup page for a non-pos client
+    //Returns:
+    //  ingredients: all ingredients from database
+    //  recipes: null (to signify non-post client)
+    //Renders merchantSetupPage
     merchantSetupNone: function(req, res){
         Ingredient.find()
             .then((ingredients)=>{
@@ -121,7 +135,10 @@ module.exports = {
             });
     },
 
-    //Display page with recipe information
+    //GET - Renders the recipe display page
+    //Returns:
+    //  merchant: merchant with recipes and recipe ingredients populated
+    //Renders recipesPage
     displayRecipes: function(req, res){
         if(!req.session.user){
             return res.render("error");

+ 6 - 6
routes.js

@@ -1,15 +1,15 @@
-const render = require("./controllers/render");
+const renderer = require("./controllers/renderer");
 const merchantData = require("./controllers/merchantData");
 const ingredientData = require("./controllers/ingredientData");
 const otherData = require("./controllers/otherData");
 
 module.exports = function(app){
     //Render page
-    app.get("/", render.landingPage);
-    app.get("/inventory", render.displayInventory);
-    app.get("/merchant/new/clover", render.merchantSetupClover);
-    app.get("/merchant/new/none", render.merchantSetupNone);
-    app.get("/recipes", render.displayRecipes);
+    app.get("/", renderer.landingPage);
+    app.get("/inventory", renderer.displayInventory);
+    app.get("/merchant/new/clover", renderer.merchantSetupClover);
+    app.get("/merchant/new/none", renderer.merchantSetupNone);
+    app.get("/recipes", renderer.displayRecipes);
 
     //Merchant
     app.get("/merchant/recipes/update", merchantData.updateRecipes);