Skip to content

Commit

Permalink
Merge pull request #117 from hngx-org/fixlistComment
Browse files Browse the repository at this point in the history
Fix list comment
  • Loading branch information
gr4yx01 authored Sep 24, 2023
2 parents fbd9405 + 96d7cf2 commit 4416143
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
8 changes: 4 additions & 4 deletions models/CommentImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
9 changes: 0 additions & 9 deletions routes/commentRoutes.js

This file was deleted.

6 changes: 5 additions & 1 deletion routes/eventRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand Down
4 changes: 0 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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);
Expand Down

0 comments on commit 4416143

Please sign in to comment.