forked from rahul130500/HAB2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
71 lines (63 loc) · 2.41 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
const express = require("express");
const flash = require("connect-flash");
const hmcRoutes = require("./routes/hmc.routes");
const announcementsRoutes = require("./routes/announcements.routes");
const aboutRoutes = require("./routes/about.routes");
const authRoutes = require("./routes/auth-routes");
const profileRoutes = require("./routes/profile-routes");
const adminRoutes = require("./routes/admin.routes");
const app = express();
const passportSetup = require("./config/passport-setup");
const mongoose = require("mongoose");
const keys = require("./config/keys");
const cookieSession = require("cookie-session");
const passport = require("passport");
const NoticeRoutes = require("./routes/notice-routes");
const MessRoutes = require("./routes/mess-routes");
const Personalweb = require("./routes/personalweb-routes");
const methodOverride = require("method-override");
require("dotenv").config();
const { MONGO_URL } = process.env;
//const NoticeAdd = require("./routes/noticeadd.routes");
// mongoose
// .connect(MONGO_URL, {
// useUnifiedTopology: true,
// useNewUrlParser: true,
// useCreateIndex: true,
// useFindAndModify: false,
// })
// .then(() => console.log("Successful DB connection"))
// .catch((err) => console.error("DB connection fail"));
// mongoose.connect(keys.mongodb.dbURI,{ useUnifiedTopology: true },()=>{
// console.log("connnected to mongodb");
// })
//harsh's mongodb
mongoose.connect("mongodb+srv://Harsh:[email protected]/habhmc?retryWrites=true&w=majority", {useNewUrlParser: true , useUnifiedTopology: true, useFindAndModify: false});
app.use(
cookieSession({
maxAgr: 24 * 60 * 60 * 1000,
keys: [keys.session.cookieKey],
})
);
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(express.urlencoded({ extended: true }));
app.use(methodOverride("_method"));
app.set("view engine", "ejs");
app.use("/uploads", express.static(__dirname + "/uploads"));
app.use("/auth", authRoutes);
app.use("/profile", profileRoutes);
app.use("/admin/notice", NoticeRoutes);
app.use("/admin/mess", MessRoutes);
app.use("/admin/hmc", hmcRoutes);
app.use("/admin/announcements", announcementsRoutes);
app.use('/admin/about',aboutRoutes);
app.use("/admin", adminRoutes);
app.use("/admin/personalweb",Personalweb);
app.get("/", (req, res) => {
res.render("home", { user: req.user });
});
app.listen(5050, () => {
console.log("app listening 5050");
});