-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserver.js
79 lines (58 loc) · 1.5 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
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
const express = require('express');
const morgan = require('morgan');
//const helmet = require('helmet');
const mongoose = require('mongoose');
const ejs = require('ejs');
const engine = require('ejs-mate');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const passport = require('passport');
const session = require('express-session');
const MongoStore = require('connect-mongo')(session);
//const passportFacebook = require('passport-facebook');
const secret = require('./config/secret');
mongoose.connect(secret.db,function(err)
{
if(err)
{
console.log(err);
}
else
{
console.log("database has been connected!");
}
});
const app = express();
app.use(express.static(__dirname+'/public'))
app.set('view engine','ejs');
app.engine('ejs',engine);
app.set('views',__dirname+'/views')
//app.use(helmet());
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(passport.initialize());
app.use(passport.session());
app.use(cookieParser());
app.use(session(
{
resave: true,
saveUnInitialized: true,
secret: secret.key,
store: new MongoStore({url: secret.db, autoReconnect: true})
}
));
//require('./routes/main')(app);
require('./routes/main')(app);
require('./routes/users')(app);
app.listen(secret.port,function(err)
{
if(err)
{
console.log(err);
}
else
{
console.log("app is running on port 4040");
}
});