-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.js
61 lines (53 loc) · 1.52 KB
/
index.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
const express=require('express');
const port=8000;
const path=require('path');
const ejs=require('ejs');
const session=require('express-session');
const cookieParser=require('cookie-parser');
const app=express();
const db=require('./config/mongoose');
const bodyParser=require('body-parser');
const Grid = require('gridfs-stream');
const passport= require('passport');
const passportLocal=require('./config/passport-local-strategy');
const passportGoogle=require('./config/passport-google-oauth2-strategy');
const layouts=require('express-ejs-layouts');
const MongoStore=require('connect-mongo')(session);
// var change=function(req,res,next){
// }
app.use(bodyParser.urlencoded({ extended: false }));
app.use(layouts);
app.use(express.static('assets'));
app.use('/uploads',express.static(__dirname+'/uploads'));
app.set('view engine', 'ejs');
app.set('views','./views');
// app.use(change);
app.use(session({
name:'Musify',
secret:'My_Secret_Key',
saveUninitialized:false,
resave:false,
cookie:{
maxAge:null
},
store:new MongoStore(
{
mongooseConnection:db,
autoRemove:'disabled'
},
function(err){
console.log(err||'connect-mongodb setup ok');
}
)
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(passport.setAuthenticatedUser)
app.use('/',require('./routes'))
app.listen(port,function(err){
if(err){
console.log('Error while Running Server');
return;
}
console.log(`Server running on port ${port}`);
});