-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
55 lines (51 loc) · 1.79 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
var YourPort = process.env.PORT
var YourIP = process.env.IP
var express = require("express");
var mongoose = require("mongoose");
var passport = require("passport"),
bodyParser = require("body-parser"),
LocalStrat = require("passport-local"),
passportLocalMongoose = require("passport-local-mongoose"),
User = require("./models/user.js"),
indexRoutes = require("./routes/indexRoutes"),
authRoutes = require("./routes/authRoutes"),
profileRoutes = require("./routes/profileRoutes"),
postRoutes = require("./routes/postRoutes"),
flash = require("connect-flash"),
messageRoutes = require("./routes/messagesRoutes"),
inviteRoutes = require("./routes/inviteRoutes");
var app = express();
//required to use body parser
app.use(bodyParser.urlencoded({extended: true}));
app.use(require("express-session")({
secret: "fmlmlmlmlmlmlmlmlmlmlmlmlmlmlmlmlmmlmlmlmmlmlmlmlmlmlmlmmmlmlmlmlmlmm",
resave:false,
saveUnitialized: false
}))
mongoose.connect("mongodb://user:password@link")
app.set("view engine","ejs");
app.use(passport.initialize());
app.use(passport.session());
mongoose.Promise = global.Promise;
passport.serializeUser(User.serializeUser());
passport.use(new LocalStrat(User.authenticate()));
passport.deserializeUser(User.deserializeUser())
app.use(flash());
app.use(function(req, res, next){
res.locals.currentuser = req.user;
next();
});
app.use(function(req,res,next){
res.locals.ide = req.params.id
next()
})
app.use(express.static(__dirname + "/public"))
app.use(indexRoutes)
app.use(authRoutes)
app.use(profileRoutes)
app.use(messageRoutes)
app.use(postRoutes)
app.use(inviteRoutes)
app.listen(YourPort,YourIP,function(){
console.log("Site started")
})