routes.js 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.post("/ingredients/create", ingredientData.createIngredient); //also adds to merchant
  26. app.put("/ingredients/update", ingredientData.updateIngredient);
  27. app.post("/ingredients/create/spreadsheet", upload.single("ingredients"), ingredientData.createFromSpreadsheet);
  28. app.get("/ingredients/download/spreadsheet", ingredientData.spreadsheetTemplate);
  29. app.delete("/ingredients/remove/:id", ingredientData.removeIngredient);
  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.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("/transactions/:from/:to", transactionData.getTransactionsByDate);
  52. app.get("/populatesometransactions", transactionData.populate);
  53. //Other
  54. app.post("/login", otherData.login);
  55. app.get("/logout", otherData.logout);
  56. app.get("/cloverlogin", otherData.cloverRedirect);
  57. app.get("/squarelogin", otherData.squareRedirect);
  58. app.get("/cloverauth*", otherData.cloverAuth);
  59. app.get("/squareauth", otherData.squareAuth);
  60. app.get("/logo", otherData.logo);
  61. //Information Pages
  62. app.get("/privacy", informationPages.privacy);
  63. app.get("/terms", informationPages.terms);
  64. app.get("/help", informationPages.help);
  65. //Email verification
  66. app.get("/verify/email/:id", emailVerification.sendVerifyEmail);
  67. app.post("/verify/resend", emailVerification.resendEmail);
  68. app.get("/verify/:id/:code", emailVerification.verify);
  69. //Password reset
  70. app.get("/reset/email", passwordReset.enterEmail);
  71. app.post("/reset/email", passwordReset.generateCode);
  72. app.get("/reset/:id/:code", passwordReset.enterPassword);
  73. app.post("/reset", passwordReset.resetPassword);
  74. }