mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 20:29:17 +00:00
📂Better folder structures and file names in backend
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const express = require("express");
|
||||
const { body } = require("express-validator");
|
||||
const User = require("../models/User");
|
||||
const authController = require("../controllers/auth");
|
||||
const SessionController = require("../controllers/SessionController");
|
||||
const UserController = require("../controllers/UserController");
|
||||
const isAuth = require("../middleware/is-auth");
|
||||
|
||||
const routes = express.Router();
|
||||
@@ -23,10 +24,10 @@ routes.post(
|
||||
body("password").trim().isLength({ min: 5 }),
|
||||
body("name").trim().not().isEmpty(),
|
||||
],
|
||||
authController.signup
|
||||
UserController.store
|
||||
);
|
||||
|
||||
routes.post("/login", authController.login);
|
||||
routes.post("/login", SessionController.store);
|
||||
|
||||
routes.get("/check", isAuth, (req, res) => {
|
||||
res.status(200).json({ authenticated: true });
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const express = require("express");
|
||||
const isAuth = require("../middleware/is-auth");
|
||||
|
||||
const ContactController = require("../controllers/contact");
|
||||
const ContactController = require("../controllers/ContactController");
|
||||
|
||||
const routes = express.Router();
|
||||
|
||||
routes.get("/contacts", isAuth, ContactController.getContacts);
|
||||
routes.get("/contacts", isAuth, ContactController.index);
|
||||
// routes.post(ContactController.postCreateContact);
|
||||
|
||||
routes.post("/contacts", isAuth, ContactController.createContact);
|
||||
routes.post("/contacts", isAuth, ContactController.store);
|
||||
|
||||
module.exports = routes;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
const express = require("express");
|
||||
const isAuth = require("../middleware/is-auth");
|
||||
|
||||
const MessangeController = require("../controllers/message");
|
||||
|
||||
const routes = express.Router();
|
||||
|
||||
routes.get(
|
||||
"/messages/:contactId",
|
||||
isAuth,
|
||||
MessangeController.getContactMessages
|
||||
);
|
||||
routes.post(
|
||||
"/messages/:contactId",
|
||||
isAuth,
|
||||
MessangeController.postCreateContactMessage
|
||||
);
|
||||
|
||||
module.exports = routes;
|
||||
11
backend/src/routes/messages.js
Normal file
11
backend/src/routes/messages.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const express = require("express");
|
||||
const isAuth = require("../middleware/is-auth");
|
||||
|
||||
const MessageController = require("../controllers/MessageController");
|
||||
|
||||
const routes = express.Router();
|
||||
|
||||
routes.get("/messages/:contactId", isAuth, MessageController.index);
|
||||
routes.post("/messages/:contactId", isAuth, MessageController.store);
|
||||
|
||||
module.exports = routes;
|
||||
@@ -6,17 +6,7 @@ const WhatsappController = require("../controllers/whatsapp");
|
||||
const routes = express.Router();
|
||||
|
||||
routes.get("/whatsapp/session", isAuth, WhatsappController.getSession);
|
||||
// routes.post(
|
||||
// "/messages/:contactId",
|
||||
// isAuth,
|
||||
// WhatsappController.postCreateContactMessage
|
||||
// );
|
||||
|
||||
routes.get("/whatsapp/contacts", isAuth, WhatsappController.getContacts);
|
||||
// routes.post(
|
||||
// "/messages/:contactId",
|
||||
// isAuth,
|
||||
// WhatsappController.postCreateContactMessage
|
||||
// );
|
||||
routes.get("/whatsapp/contacts", isAuth, WhatsappController.getContacts); // fetch contacts in user cellphone, not in use
|
||||
|
||||
module.exports = routes;
|
||||
|
||||
Reference in New Issue
Block a user