-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
42 lines (34 loc) · 1.08 KB
/
server.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
var express = require("express"),
path = require("path"),
mongoose = require("mongoose"),
bodyParser = require("body-parser"),
passport = require("passport"),
cookieParser = require("cookie-parser"),
session = require("express-session"),
routes = require("./app/routes/route"),
passportLogic = require("./passport/index"),
flash = require("connect-flash"),
app = express(),
Users = require("./model/index"),
localDB = "mongodb://127.0.0.1:27017/poll";
app.set("view engine", "ejs");
app.use(express.static(path.join(__dirname, "public")));
app.set("port", (process.env.PORT || 3000));
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(cookieParser());
app.use(session({
secret: "fuck you",
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
mongoose.connect(process.env.MONGOLAB_URI || localDB);
passportLogic(Users);
routes(app, passport, Users);
app.listen(app.get("port"), function () {
console.log("Listening to port " + app.get("port"));
});