const {authJwt} = require("../middlewares");

module.exports = app => {
    const messages = require("../controllers/message.controller.js");
    app.use((req, res, next) => {
      res.header(
        "Access-Control-Allow-Headers",
        "x-access-token, Origin, Content-Type, Accept"
      );
      next();
    });
    var router = require("express").Router();
    // Retrieve all messages
    router.get("/",[authJwt.verifyToken], messages.getAllMessages);
    // Create a new message
    router.post("/", [authJwt.verifyToken], messages.createMessage);
    // Bulk create messages
    router.post("/bulk", [authJwt.verifyToken], messages.createMessages);
    // Update an message
    router.put("/:id",[authJwt.verifyToken], messages.updateMessage );
    // Get messages by Date and Type
    router.get("/:id", [authJwt.verifyToken], messages.getMessage);
    router.get("/sent-messages/all", [authJwt.verifyToken], messages.getAllSentMessages);
    router.get("/public/search", messages.getMessagesByGroupAndLanguage);
    router.post("/public/send", [authJwt.verifyToken], messages.sendMessage);
    app.use('/api/messages', router);
 };