-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (38 loc) · 1.39 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
const path = require('path');
const dotenv = require('dotenv');
dotenv.config();
const express = require('express');
const session = require('express-session');
const flash = require('express-flash');
const passport = require('passport');
const app = express();
app.set('port', process.env.APP_PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use('/static', express.static(path.join(__dirname, 'static')));
const { loginAuth } = require('./config/passport');
loginAuth(passport);
app.use(express.urlencoded({ extended: true }));
app.use(session({
secret: process.env.APP_SESSION_SECRET,
saveUninitialized: false,
resave: false,
cookie: {
maxAge: (3600000) * (process.env.APP_SESSION_COOKIE_MAXAGE || 12) // APP_SESSION_COOKIE_MAXAGE sa valeur par défaut est 12 et est en heures
}
}));
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use((req, res, next) => {
req.mailer_transporter = require('./config/mailer');
res.locals.SITE_NAME = process.env.APP_NAME || null;
res.locals.USER = req.user || null;
next();
});
app.use('/', require('./routes/indexRoutes'));
app.use('/dashboard', require('./routes/dashboardRoutes'));
app.use('/auth', require('./routes/authRoutes'));
app.listen(app.get('port'), () => {
console.log('Application lancée sur le port : ', app.get('port'));
});