-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (27 loc) · 794 Bytes
/
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
const express = require('express');
const session = require('express-session');
const passport = require('passport');
const flash = require('connect-flash');
const app = express();
app.set('view engine', 'ejs');
// Middleware
app.use(express.urlencoded({ extended: false }));
app.use(session({
secret: 'secret',
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use((req, res, next) => {
res.locals.user = req.user || null;
next();
});
// Rotas
app.use('/', require('./routes/index'));
app.use('/auth', require('./routes/auth'));
// Servir arquivos estáticos
app.use(express.static('public'));
const PORT = process.env.PORT || 3000;
app.listen(PORT, console.log(`Server started on port ${PORT}`));