This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
101 lines (86 loc) · 4.03 KB
/
index.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const express = require("express");
const app = express();
const bodyParser = require("body-parser");
const cors = require("cors");
const cookieParser = require("cookie-parser");
const indexRouter = require("./Router/indexRouter");
const updateNoticeRouter = require("./Router/updateNotice/updateNoticeRouter");
const updateViewRouter = require("./Router/updateView/updateViewRouter");
const checkLikeRouter = require("./Router/checkLike/checkLikeRouter");
const checkCookieRouter = require("./Router/checkCookie/checkCookieRouter");
const checkUserRouter = require("./Router/checkUser/checkUserRouter");
const getLandingPostRouter = require("./Router/getLandingPost/getLandingPostRouter");
const getAskRouter = require("./Router/getAsk/getAskRouter");
const getLikeRouter = require("./Router/getLike/getLikeRouter");
const getCommentItemRouter = require("./Router/getCommentItem/getCommentItemRouter");
const getCommentListRouter = require("./Router/getCommentList/getCommentListRouter");
const getRankingRouter = require("./Router/getRanking/getRankingRouter");
const getReplysRouter = require("./Router/getReplys/getReplysRouter");
const getPostTagRouter = require("./Router/getPostTag/getPostTagRouter");
const getTagPageRouter = require("./Router/getTagPage/getTagPageRouter");
const getLoginRouter = require("./Router/getLogIn/getLoginRegister");
const getUserAuthRouter = require("./Router/getUserAuth/getUserAuthRouter");
const getUserInfoRouter = require("./Router/getUserInfo/getUserInfoRouter");
const getUserPostRouter = require("./Router/getUserPost/getUserPostRouter");
const getNoticeRouter = require("./Router/getNotice/getNoticeRouter");
const setImgRouter = require("./Router/setImg/setImgRouter");
const setRegisterRouter = require("./Router/setRegister/setRegisterRouter");
const setPostRouter = require("./Router/setPost/setPostRouter");
const setLikeRouter = require("./Router/setLike/setLikeRouter");
const setLikeInitRouter = require("./Router/setLike/setLikeInitRouter");
const setReplyRouter = require("./Router/setReply/setReplyRouter");
const setCommentRouter = require("./Router/setComment/setCommentRouter");
const removeCookieRouter = require("./Router/removeCookie/removeCookieRouter");
const removePostRouter = require("./Router/removePost/removePostRouter");
// middleware 순서 이슈??
// https://stackoverflow.com/questions/16209145/how-can-i-set-cookie-in-node-js-using-express-framework
app.use(cookieParser());
app.use("/img", express.static("img"));
// https://kosaf04pyh.tistory.com/152
// origin 설정 필요한가봄.
app.use(
cors({
// origin: "https://whyrano.site",
origin: [
"http://localhost:3000",
"https://whyrano.site",
"https://tadfafsaest.whyrano.site",
],
credentials: true,
}),
);
// app.use(cors);
app.use(bodyParser.json());
app.use(indexRouter);
app.use("/updateNotice", updateNoticeRouter);
app.use("/updateView", updateViewRouter);
app.use("/checkLike", checkLikeRouter);
app.use("/checkCookie", checkCookieRouter);
app.use("/checkUser", checkUserRouter);
app.use("/getAsk", getAskRouter);
app.use("/getCommentItem", getCommentItemRouter);
app.use("/getCommentList", getCommentListRouter);
app.use("/getLandingPost", getLandingPostRouter);
app.use("/getLike", getLikeRouter);
app.use("/getRanking", getRankingRouter);
app.use("/getReplys", getReplysRouter);
app.use("/getPostTag", getPostTagRouter);
app.use("/getTagPage", getTagPageRouter);
app.use("/getLogin", getLoginRouter);
app.use("/getUser", getUserInfoRouter);
app.use("/getUserAuth", getUserAuthRouter);
app.use("/getUserPost", getUserPostRouter);
app.use("/getNotice", getNoticeRouter);
app.use("/setImg", setImgRouter);
app.use("/setRegister", setRegisterRouter);
app.use("/setReply", setReplyRouter);
app.use("/setpost", setPostRouter);
app.use("/setLike", setLikeRouter);
app.use("/setLikeInit", setLikeInitRouter);
app.use("/setComment", setCommentRouter);
app.use("/removeCookie", removeCookieRouter);
app.use("/removePost", removePostRouter);
const port = 5050;
app.listen(port, () => {
console.log(`Listening at http://localhost:${port}`);
});