routes.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. const renderer = require("./controllers/renderer");
  2. const merchantData = require("./controllers/merchantData");
  3. const ingredientData = require("./controllers/ingredientData");
  4. const otherData = require("./controllers/otherData");
  5. const transactionData = require("./controllers/transactionData");
  6. const recipeData = require("./controllers/recipeData");
  7. const orderData = require("./controllers/orderData.js");
  8. const informationPages = require("./controllers/informationPages.js");
  9. const emailVerification = require("./controllers/emailVerification.js");
  10. const passwordReset = require("./controllers/passwordReset.js");
  11. const squareData = require("./controllers/squareData.js");
  12. const admin = require("./controllers/admin.js");
  13. const session = require("./middleware.js").verifySession;
  14. const banner = require("./middleware.js").formatBanner;
  15. module.exports = function(app){
  16. //Render page
  17. app.get("/", banner, renderer.landingPage);
  18. app.get("/login", banner, renderer.loginPage);
  19. app.get("/register", banner, renderer.registerPage);
  20. app.get("/dashboard", session, renderer.displayDashboard);
  21. app.get("/resetpassword/*", renderer.displayPassReset);
  22. //Merchant
  23. app.post("/merchant/create/none", merchantData.createMerchantNone);
  24. app.post("/merchant/add/none", session, merchantData.addMerchantNone);
  25. app.put("/merchant/ingredients/update", session, merchantData.updateIngredientQuantities); //also updates some data in ingredients
  26. app.post("/merchant/password", merchantData.updatePassword); //TODO: change to work with session
  27. app.put("/merchant/update", session, merchantData.updateData);
  28. app.put("/merchant/password", session, merchantData.changePassword);
  29. app.delete("/merchant", session, merchantData.deleteMerchant);
  30. app.get("/merchant/:id", merchantData.getMerchant);
  31. //Ingredients
  32. app.post("/ingredients/create", session, ingredientData.createIngredient); //also adds to merchant
  33. app.put("/ingredients/update", session, ingredientData.updateIngredient);
  34. app.put("/ingredients/subingredients", session, ingredientData.updateSubIngredients);
  35. app.delete("/ingredients/remove/:id", session, ingredientData.removeIngredient);
  36. //Recipes
  37. app.post("/recipe/create", session, recipeData.createRecipe);
  38. app.put("/recipe/update", session, recipeData.updateRecipe);
  39. app.delete("/recipe/remove/:id", session, recipeData.removeRecipe);
  40. app.get("/recipes/hide/:id", session, recipeData.hideRecipe);
  41. //Orders
  42. app.post("/orders/get", session, orderData.getOrders);
  43. app.post("/order/create", session, orderData.createOrder);
  44. app.delete("/order/:id", session, orderData.removeOrder);
  45. //Transactions
  46. app.post("/transaction", session, transactionData.getTransactions);
  47. app.post("/transaction/create", session, transactionData.createTransaction);
  48. app.delete("/transaction/:id", session, transactionData.remove);
  49. app.get("/populatesometransactions", session, transactionData.populate);
  50. //Other
  51. app.post("/login", otherData.login);
  52. app.get("/logout", otherData.logout);
  53. app.post("/feedback", session, otherData.feedback);
  54. app.get("/session/end", session, otherData.endSession);
  55. //Information Pages
  56. app.get("/privacy", informationPages.privacy);
  57. app.get("/terms", informationPages.terms);
  58. app.get("/help", informationPages.help);
  59. //Email verification
  60. app.get("/verify/email/:id", banner, emailVerification.sendVerifyEmail);
  61. app.post("/verify/resend", emailVerification.resendEmail);
  62. app.get("/verify/:id/:code", emailVerification.verify);
  63. //Password reset
  64. app.get("/reset/email", passwordReset.enterEmail);
  65. app.post("/reset/email", passwordReset.generateCode);
  66. app.get("/reset/:id/:code", banner, passwordReset.enterPassword);
  67. app.post("/reset", passwordReset.resetPassword);
  68. //Square
  69. app.post("/squarelogin", squareData.redirect);
  70. app.get("/squareauth", squareData.createMerchant);
  71. app.get("/recipes/update/square", session, squareData.updateRecipes);
  72. app.get("/square/locations", session, squareData.getLocations);
  73. app.get("/square/add/:location", session, squareData.addMerchant);
  74. //Admin
  75. app.get("/admin/create", (req, res)=>{res.sendFile(`${__dirname}/views/newTest.html`)});
  76. app.post("/admin/create", session, admin.addData);
  77. }