forked from ServerSystem-7/Mechurial_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
119 lines (98 loc) · 4.17 KB
/
main.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const express = require("express"),
app = express(),
router = express.Router(),
errorController = require("./controllers/errorController"),
homeController=require("./controllers/homeController"),
signUpController=require("./controllers/signUpController"),
registerController = require("./controllers/registerController"),
userController=require("./controllers/userController"),
myPageController=require("./controllers/myPageController"),
session = require("express-session"),
crawling = require("./crawl_main"),
db = require('./models/index');
app.set("port", process.env.PORT || 80);
app.set("view engine", "ejs");
app.use("/public", express.static(__dirname + "/public"));
router.use (
express.urlencoded({
extended : false
})
);
router.use(express.static("public"));
router.use(express.json());
app.use(
session({
key: 'sid',
secret: "secret",
cookie: {
httpOnly: true,
maxAge: 4000000
},
resave: false,
saveUninitialized: false,
nickname: 'id'
})
);
db.sequelize.sync({ alter: false })
.then(() => {
console.log('데이터베이스 연결 성공.');
})
.catch((error) => {
console.error(error);
});
router.get("/", homeController.homePage);
// 등록 관련 라우터
router.get("/register/new", registerController.new);
router.post("/register/create", registerController.create, registerController.redirectView);
router.get("/registerManagement", registerController.show);
router.post("/registerManagement/:registerId/delete", registerController.delete, registerController.redirectView);
router.get("/registerManagement/:registerId/edit", registerController.edit);
router.post("/registerManagement/:registerId/update", registerController.update, registerController.redirectView);
// 회원가입 관련 라우터
router.get("/signUp/terms", signUpController.signUp_terms);
router.get("/signUp", signUpController.signUp_main);
router.post("/signUp/idChk", signUpController.idChk);
router.post("/signUp/create", signUpController.createUser);
router.post("/signUp/sendmail", signUpController.sendMail);
router.post("/signUp/emailcert", signUpController.emailCert);
router.get("/signUp/complete", signUpController.signUp_complete);
// 로그인 관련 라우터
router.get("/logIn_main", userController.login);
router.post("/logIn_main", userController.authenticate);
router.get("/logOut_main", userController.logout);
// 회원정보 관련 라우터
router.get("/mypage_main",myPageController.enterMypage);
// 1. 아이디 찾기 관련 라우터
router.get("/search_id", userController.searchid);
router.post("/search_id/sendmail", userController.sendMail_cerNum);
router.post("/search_id/emailcert", userController.checkCerNum, userController.sendMail_id);
router.post("/id_search_1", userController.authenticate);
// 2. 비밀번호 찾기 관련 라우터
router.get("/search_pw", userController.searchPw);
router.post("/search_pw/sendmail", userController.sendMail_cerNum);
router.post("/search_pw", userController.checkIdEmail);
router.get("/search_pw/new", userController.showInputNewPw)
// 3. 회원정보 조회를 위한 비밀번호 확인
router.get("/mypage/check", myPageController.showCheckPw);
// 4. 비밀번호 변경 관련 라우터
router.get("/mypage_pw",userController.changePW);
router.post("/mypage/checkpw",myPageController.checkPw);
router.post("/mypage/changepw",userController.applyNewPw);
// 5. 이메일 변경 관련 라우터
router.get("/mypage_email",userController.showChangeEmail);
router.post("/mypage/checkemail",userController.checkNewEmail);
router.post("/mypage/emailcert",userController.checkCerNum, userController.cerNumOk);
router.post("/mypage/changemail",userController.applyNewEmail);
//6. 회원 탈퇴 라우터
router.post("/mypage_main", userController.deleteUser);
app.get("/serviceInfo", homeController.showserviceInfo);
app.get("/logIn_main", homeController.showLogin);
router.use(errorController.pageNotFoundError);
router.use(errorController.internalServerError);
app.use("/", router);
app.listen(app.get("port"), () => {
console.log(`Server running at ${app.get("port")}`);
});
// app.listen(app.get("port"), () => {
// console.log(`Server running at http://localhost:${app.get("port")}`);
// });