-
Notifications
You must be signed in to change notification settings - Fork 1
/
router.js
80 lines (56 loc) · 2.9 KB
/
router.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const router = require("express").Router();
const passport = require("passport");
const { ensureAuth } = require("./middleware/ensureAuth");
const likeController = require("./controlers/like");
const postController = require("./controlers/post");
const pageController = require("./controlers/page");
const authController = require("./controlers/auth");
const userController = require("./controlers/user");
const commentController = require("./controlers/comment");
const notificationController = require("./controlers/notification");
const friendshipController = require("./controlers/friendship");
router.get("/", pageController.home);
router.get("/login", pageController.login);
router.get("/register", pageController.register);
router.get("/profile/:userid", ensureAuth, pageController.profile);
router.get("/all", ensureAuth, pageController.all);
router.get("/post/:id", ensureAuth, pageController.post);
router.post("/users/update/:userid", ensureAuth, userController.update);
router.get("/auth/google", authController.google);
router.get("/auth/google/home", authController.googleCallback);
router.get("/auth/logout", authController.logout);
router.post("/auth/register", authController.register);
router.post("/auth/login", authController.login);
//like post router
router.post("/users/like", ensureAuth, likeController.create);
router.delete("/users/like", ensureAuth, likeController.delete);
//comment post
router.post("/users/comment", ensureAuth, commentController.create);
router.delete("/users/comment", ensureAuth, commentController.delete);
//update comment
router.post("/users/comment/update", ensureAuth, commentController.update);
//get comments from post
router.get(
"/post/:postId/comment",
ensureAuth,
commentController.getCommentsByPostId
);
//upload a post
router.post("/users/post", ensureAuth, postController.create);
router.delete("/users/post", ensureAuth, postController.delete);
//update post
router.post("/users/post/update", ensureAuth, postController.update);
//search
router.post("/users/search", ensureAuth, userController.search);
//notifications
router.post("/notification/friend-request/create", ensureAuth, notificationController.createFriendRequest);
router.post("/notification/like/create", ensureAuth, notificationController.createLikeNotification);
router.delete("/notification/like/delete", ensureAuth, notificationController.deleteByLike);
router.post("/notification/comment/create", ensureAuth, notificationController.createCommentNotification);
router.delete("/notification/comment/delete", ensureAuth, notificationController.deleteByComment);
router.post("/notification/:id/seen", ensureAuth, notificationController.updateSeen);
//friend request
router.post("/friendship/accept", ensureAuth, friendshipController.accept);
router.delete("/friendship", ensureAuth, friendshipController.delete);
router.delete("/friendship/undo", ensureAuth, friendshipController.undo);
module.exports = router;