-
Notifications
You must be signed in to change notification settings - Fork 2
/
router.js
70 lines (63 loc) · 1.89 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
const express = require("express");
const router = express.Router();
const userController = require("./controllers/userController");
const postController = require("./controllers/postController");
const followController = require("./controllers/followController");
// user related routes
router.get("/", userController.home);
router.post("/register", userController.register);
router.post("/login", userController.login);
router.post("/logout", userController.logout);
router.post("/doesUsernameExist", userController.doesUsernameExist);
router.post("/doesEmailExist", userController.doesEmailExist);
// profile related routes
router.get(
"/profile/:username",
userController.ifUserExists,
userController.sharedProfileData,
userController.profilePostsScreen
);
router.get(
"/profile/:username/followers",
userController.ifUserExists,
userController.sharedProfileData,
userController.profileFollowersScreen
);
router.get(
"/profile/:username/following",
userController.ifUserExists,
userController.sharedProfileData,
userController.profileFollowingScreen
);
// posts related routes
router.get(
"/create-post",
userController.mustBeLoggedIn,
postController.viewCreateScreen
);
router.post(
"/create-post",
userController.mustBeLoggedIn,
postController.create
);
router.get("/post/:id", postController.viewSingle);
router.get(
"/post/:id/edit",
userController.mustBeLoggedIn,
postController.viewEditScreen
);
router.post(
"/post/:id/edit",
userController.mustBeLoggedIn,
postController.edit
);
router.post(
"/post/:id/delete",
userController.mustBeLoggedIn,
postController.delete
);
router.post('/search', postController.search)
// follow related routes
router.post('/addFollow/:username', userController.mustBeLoggedIn, followController.addFollow);
router.post('/removeFollow/:username', userController.mustBeLoggedIn, followController.removeFollow);
module.exports = router;