-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
173 lines (149 loc) · 4.01 KB
/
app.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
const express = require("express");
const bodyParser = require("body-parser");
const bcrypt = require("bcrypt");
const mongoose = require("mongoose");
const port = process.env.PORT || 8080;
const User = require("./models/User.js");
const Question = require("./models/question.model.js");
const paradoxUser = require("./models/paradoxUser.model.js");
// const authController = require("./controllers/auth.controller.js");
const userController = require("./controllers/user.controller.js");
const hashVerifier = require("./middleware/authMiddleware.js");
const authRoutes = require("./routes/auth.routes");
// const homeRoutes = require("./routes/homePage.routes.js");
const homeController = require("./controllers/homePage.controller.js");
// level1 Routes
const { checkQues } = require("./controllers/play_level1.controller.js");
const level1Routes = require("./routes/play_level1.routes.js");
const level2Routes = require("./routes/play_level2.routes.js");
// add question routes
const addQuesRoutes = require("./utils/ques_collector_api.js");
// rules controller
const { getRules } = require("./controllers/rules.controller.js");
// leaderboard routes
const leaderBoardRoutes = require("./routes/leaderboard.routes.js");
// profile routes
// let profileRoutes = require("./routes/profile.route.js");
const { displayProfile } = require("./controllers/profile.controller");
const { getPrize } = require("./controllers/prize.controller.js");
// const teamRoutes = require("./routes/team.routes.js");
const {
joinTeam,
createTeam,
getTeamDetails,
} = require("./controllers/team.controller.js");
const { getQues, cAns } = require("./controllers/play_level2.controller.js");
const questionModel = require("./models/question.model.js");
const { update } = require("./utils/top50creater.js");
const app = express();
app.set("view engine", "ejs");
app.use(bodyParser.json());
app.use(express.static("public"));
require("dotenv").config();
// middleware
// database connection
app.post(
"/home",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
homeController.homePage
);
app.use(
"/auth",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
authRoutes
);
// collector api
app.use("/addQues", addQuesRoutes);
// rules api
app.use(
"/rules",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
getRules
);
// Level 1 route
app.use(
"/play/level1",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
level1Routes
);
// Leaderboard route
app.use(
"/leaderboard",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
leaderBoardRoutes
);
// app.post("/signup", authController.signup_post);
// app.post("/login", authController.login_post);
app.post(
"/createUser",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
userController.CreateUser
);
app.use(
"/profile",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
displayProfile
);
app.use(
"/prizes",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
getPrize
);
app.post(
"/team/join",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
joinTeam
);
app.post(
"/team/create",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
createTeam
);
app.post(
"/team/details",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
getTeamDetails
);
// Level 2 Team
app.use(
"/play/level2/",
hashVerifier.base64Decoder,
hashVerifier.md5HashVerifier,
level2Routes
);
// app.get("/", (req, res) => {
// paradoxUser.updateMany({}, { $set: { isInTop: false } }, (err, res) => {
// if (err) {
// console.log(err);
// } else {
// console.log("New field added to all existing documents");
// }
// });
// });
app.get("/", (req, res) => {
res.send("v4");
});
mongoose
.connect(
`mongodb+srv://AkhilJ321:KfMcvxsZcOo08iZl@cluster0.2nfriob.mongodb.net/test`
)
.then((result) => {
console.log("Database Connected!!");
app.listen(port, () => {
console.log("lets goo");
});
})
.catch((err) => {
console.log(err);
});