-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
67 lines (51 loc) · 1.76 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
require('./models/db');
const express =require('express');
const path =require('path');
const exphbs=require('express-handlebars');
//const expressLayouts=require('express-ejs-layouts');
const bodyparser =require('body-parser');
const flash=require('connect-flash');
const session =require('express-session');
const logger= require('morgan');
var favicon = require('serve-favicon');
const userController = require('./controllers/userControllers');
const profileController = require('./controllers/profileController');
const groupController=require('./controllers/groupController');
const passport =require('passport');
var app = express();
var cons = require('consolidate');
require('./config/passport')(passport);
app.use(logger('dev'));
// express session
app.use(session({
secret: 'secret key',
resave: false,
saveUninitialized: false,
}));
app.use(flash());
app.use((req,res,next) => {
res.locals.success_msg = req.flash('success_msg');
res.locals.error_msg = req.flash('error_msg');
res.locals.error = req.flash('error');
res.locals.Uusername=req.flash('Uusername');
next();
});
app.locals.authenticated='gg';
app.use(passport.initialize());
app.use(passport.session());
app.set('view engine', 'ejs');
app.use(express.urlencoded({extended : false}));
app.use(express.static(path.join(__dirname, 'public')));
app.use(favicon(path.join(__dirname, 'public/img', 'favicon.ico')))
const port = process.env.PORT || 3000;
app.use((req, res, next) => {
if (!req.user)
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
next();
});
app.listen(port, function() {
console.log('Your node is running on port 3000 !!!')
});
app.use('/',userController);
app.use('/profile',profileController);
app.use('/profile/group',groupController);