globalRouter.js
1.13 KB
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
import express from "express";
import passport from "passport";
import routes from "../routes";
import { home, search } from "../controllers/videoController";
import {
getJoin,
getLogin,
logout,
postJoin,
postLogin,
githubLogin,
postGithubLogin,
getMe,
} from "../controllers/userController";
import { onlyPublic, onlyPrivate } from "../middlewares";
const globalRouter = express.Router();
globalRouter.get(routes.join, onlyPublic, getJoin);
globalRouter.post(routes.join, onlyPublic, postJoin, postLogin);
globalRouter.get(routes.login, onlyPublic, getLogin);
globalRouter.post(routes.login, onlyPublic, postLogin);
globalRouter.get(routes.home, home);
globalRouter.get(routes.search, search);
globalRouter.get(routes.logout, onlyPrivate, logout);
globalRouter.get(routes.gitHub, githubLogin);
// callback으로 받아온 정보를 다뤄야하는 함수도 필요하다.
// callback으로 가면 passport.authenticate 처리 해줘야함
globalRouter.get(
routes.githubCallback,
passport.authenticate("github", { failureRedirect: "/login" }),
postGithubLogin
);
globalRouter.get(routes.me, getMe);
export default globalRouter;