diff --git a/models/CommentImages.js b/models/CommentImages.js index 6a4a49a..2c14e2f 100644 --- a/models/CommentImages.js +++ b/models/CommentImages.js @@ -28,10 +28,10 @@ const CommentImages = db.define( { timestamps: false, underscored: true }, ); -CommentImages.belongsTo(Comment, {foreignKey: "comment_id"}) -CommentImages.belongsTo(Image, {foreignKey: "image_id"}) +CommentImages.belongsTo(Comment, { foreignKey: "comment_id" }); +CommentImages.belongsTo(Image, { foreignKey: "image_id" }); -Comment.hasMany(CommentImages, {foreignKey: "comment_id"}) -Image.hasMany(CommentImages, {foreignKey: "image_id"}) +Comment.hasMany(CommentImages, { foreignKey: "comment_id" }); +Image.hasMany(CommentImages, { foreignKey: "image_id" }); export default CommentImages; diff --git a/routes/commentRoutes.js b/routes/commentRoutes.js deleted file mode 100644 index ec2b16d..0000000 --- a/routes/commentRoutes.js +++ /dev/null @@ -1,9 +0,0 @@ -import express from "express"; -import { listComments } from "../controllers/commentController/index.js"; -import { userAuthorisation } from "../middleware/authorization.js"; - -const commentRouter = express.Router(); - -commentRouter.get("/events/:eventId/comments", userAuthorisation, listComments); - -export default commentRouter; diff --git a/routes/eventRoutes.js b/routes/eventRoutes.js index 342ea44..9cf9699 100644 --- a/routes/eventRoutes.js +++ b/routes/eventRoutes.js @@ -7,7 +7,10 @@ import { } from "../controllers/eventController/index.js"; import validate from "../middleware/validation.js"; -import { AddCommentToEvent } from "../controllers/commentController/index.js"; +import { + AddCommentToEvent, + listComments, +} from "../controllers/commentController/index.js"; import { userAuthorisation } from "../middleware/authorization.js"; const eventRouter = express.Router(); @@ -19,6 +22,7 @@ eventRouter.post("/events", userAuthorisation, validate.Event, createEvent); eventRouter.get("/events", userAuthorisation, listAllEvents); eventRouter.get("/events/:id", userAuthorisation, getEventDetails); eventRouter.delete("/events/:id", userAuthorisation, deleteEvent); +eventRouter.get("/events/:eventId/comments", userAuthorisation, listComments); eventRouter.post("/events/:eventId", userAuthorisation, AddCommentToEvent); diff --git a/routes/index.js b/routes/index.js index e6c7f34..83b4490 100644 --- a/routes/index.js +++ b/routes/index.js @@ -4,7 +4,6 @@ import userRouter from "./userRoutes.js"; import ImageRouter from "./ImageRoutes.js"; import eventRouter from "./eventRoutes.js"; import groupRouter from "./groupRoutes.js"; -import commentRouter from "./commentRoutes.js"; import likeRouter from "./likeRouter.js"; import authRouter from "./authRoute.js"; @@ -18,9 +17,6 @@ router.use(authRouter); //describe the event routes router.use(ImageRouter); router.use(groupRouter); - -router.use(commentRouter); - router.use(eventRouter); router.use(likeRouter);