routes.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 session = require("./verifySession.js");
  12. const multer = require("multer");
  13. const upload = multer({dest: "uploads/"});
  14. module.exports = function(app){
  15. //Render page
  16. app.get("/", renderer.landingPage);
  17. app.get("/dashboard", session, renderer.displayDashboard);
  18. app.get("/resetpassword/*", renderer.displayPassReset);
  19. //Merchant
  20. app.post("/merchant/create/none", merchantData.createMerchantNone);
  21. app.get("/merchant/create/clover", merchantData.createMerchantClover);
  22. app.get("/merchant/create/square", merchantData.createMerchantSquare);
  23. app.put("/merchant/ingredients/update", merchantData.updateMerchantIngredient); //also updates some data in ingredients
  24. app.post("/merchant/password", merchantData.updatePassword);
  25. //Ingredients
  26. app.post("/ingredients/create", session, ingredientData.createIngredient); //also adds to merchant
  27. app.put("/ingredients/update", session, ingredientData.updateIngredient);
  28. app.post("/ingredients/create/spreadsheet", session, upload.single("ingredients"), ingredientData.createFromSpreadsheet);
  29. app.get("/ingredients/download/spreadsheet", session, ingredientData.spreadsheetTemplate);
  30. app.delete("/ingredients/remove/:id", session, ingredientData.removeIngredient);
  31. //Recipes
  32. app.post("/recipe/create", recipeData.createRecipe);
  33. app.put("/recipe/update", recipeData.updateRecipe);
  34. app.delete("/recipe/remove/:id", recipeData.removeRecipe);
  35. app.get("/recipe/update/clover", recipeData.updateRecipesClover);
  36. app.get("/recipe/update/square", recipeData.updateRecipesSquare);
  37. app.post("/recipes/create/spreadsheet", upload.single("recipes"), recipeData.createFromSpreadsheet);
  38. app.get("/recipes/download/spreadsheet", recipeData.spreadsheetTemplate);
  39. //Orders
  40. app.post("/orders/get", orderData.getOrders);
  41. app.post("/order/create", orderData.createOrder);
  42. app.post("/orders/create/spreadsheet", upload.single("orders"), orderData.createFromSpreadsheet);
  43. app.get("/orders/download/spreadsheet", orderData.spreadsheetTemplate);
  44. app.delete("/order/:id", orderData.removeOrder);
  45. //Transactions
  46. app.post("/transaction", transactionData.getTransactions);
  47. app.post("/transaction/create", transactionData.createTransaction);
  48. app.post("/transactions/create/spreadsheet", upload.single("transactions"), transactionData.createFromSpreadsheet);
  49. app.get("/transactions/download/spreadsheet", transactionData.spreadsheetTemplate);
  50. app.delete("/transaction/:id", transactionData.remove);
  51. app.get("/populatesometransactions", transactionData.populate);
  52. //Other
  53. app.post("/login", otherData.login);
  54. app.get("/logout", otherData.logout);
  55. app.get("/cloverlogin", otherData.cloverRedirect);
  56. app.get("/squarelogin", otherData.squareRedirect);
  57. app.get("/cloverauth*", otherData.cloverAuth);
  58. app.get("/squareauth", otherData.squareAuth);
  59. app.get("/logo", otherData.logo);
  60. //Information Pages
  61. app.get("/privacy", informationPages.privacy);
  62. app.get("/terms", informationPages.terms);
  63. app.get("/help", informationPages.help);
  64. //Email verification
  65. app.get("/verify/email/:id", emailVerification.sendVerifyEmail);
  66. app.post("/verify/resend", emailVerification.resendEmail);
  67. app.get("/verify/:id/:code", emailVerification.verify);
  68. //Password reset
  69. app.get("/reset/email", passwordReset.enterEmail);
  70. app.post("/reset/email", passwordReset.generateCode);
  71. app.get("/reset/:id/:code", passwordReset.enterPassword);
  72. app.post("/reset", passwordReset.resetPassword);
  73. }