import { ChatController } from "@/controllers/chatController.js";
import { authenticateToken } from "@/middleware/auth.js";
import {
  addChatRoomMemberSchema,
  createChatRoomSchema,
  removeChatRoomMemberSchema,
  updateChatRoomSchema,
  validate,
} from "@/middleware/validation.js";
import { Router } from "express";

const router = Router();

router.use(authenticateToken);

router.get("/chat-rooms", ChatController.getChatRooms);
router.post("/chat-rooms", validate(createChatRoomSchema), ChatController.createChatRoom);
router.put("/chat-rooms/:roomId", validate(updateChatRoomSchema), ChatController.updateChatRoom);
router.delete("/chat-rooms/:roomId", ChatController.deleteChatRoom);
router.post("/chat-rooms/:roomId/members", validate(addChatRoomMemberSchema), ChatController.addChatRoomMember);
router.delete("/chat-rooms/:roomId/members", validate(removeChatRoomMemberSchema), ChatController.removeChatRoomMember);
router.get("/messages/:roomId", ChatController.getMessages);

export { router as chatRoutes };
