routes.js 4.0 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 multer = require("multer");
  12. const upload = multer({dest: "uploads/"});
  13. module.exports = function(app){
  14. //Render page
  15. app.get("/", renderer.landingPage);
  16. app.get("/dashboard", renderer.displayDashboard);
  17. app.get("/resetpassword/*", renderer.displayPassReset);
  18. //Merchant
  19. app.post("/merchant/create/none", merchantData.createMerchantNone);
  20. app.get("/merchant/create/clover", merchantData.createMerchantClover);
  21. app.get("/merchant/create/square", merchantData.createMerchantSquare);
  22. app.put("/merchant/ingredients/update", merchantData.updateMerchantIngredient); //also updates some data in ingredients
  23. app.post("/merchant/password", merchantData.updatePassword);
  24. //Ingredients
  25. app.get("/ingredients", ingredientData.getIngredients);
  26. app.post("/ingredients/create", ingredientData.createIngredient); //also adds to merchant
  27. app.put("/ingredients/update", ingredientData.updateIngredient);
  28. app.delete("/ingredients/remove/:id", ingredientData.removeIngredient);
  29. app.post("/ingredients/create/spreadsheet", upload.single("ingredients"), ingredientData.createFromSpreadsheet);
  30. //Recipes
  31. app.post("/recipe/create", recipeData.createRecipe);
  32. app.put("/recipe/update", recipeData.updateRecipe);
  33. app.delete("/recipe/remove/:id", recipeData.removeRecipe);
  34. app.get("/recipe/update/clover", recipeData.updateRecipesClover);
  35. app.get("/recipe/update/square", recipeData.updateRecipesSquare);
  36. app.post("/recipes/create/spreadsheet", upload.single("recipes"), recipeData.createFromSpreadsheet);
  37. app.get("/recipes/download/spreadsheet", recipeData.spreadsheetTemplate);
  38. //Orders
  39. app.get("/order", orderData.getOrders);
  40. app.post("/order", orderData.orderFilter);
  41. app.post("/order/create", orderData.createOrder);
  42. app.delete("/order/:id", orderData.removeOrder);
  43. app.post("/orders/create/spreadsheet", upload.single("orders"), orderData.createFromSpreadsheet);
  44. app.get("/orders/download/spreadsheet", orderData.spreadsheetTemplate);
  45. //Transactions
  46. app.post("/transaction", transactionData.getTransactions);
  47. app.get("/transactions/:from/:to", transactionData.getTransactionsByDate);
  48. app.post("/transaction/create", transactionData.createTransaction);
  49. app.delete("/transaction/:id", transactionData.remove);
  50. app.post("/transactions/create/spreadsheet", upload.single("transactions"), transactionData.createFromSpreadsheet);
  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.get("/verify/:id", emailVerification.verifyPage);
  67. app.post("/verify", 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. }