-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
36 lines (31 loc) · 1.15 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
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var exphbs = require('express-handlebars');
var express = require('express');
var expressSession = require('express-session');
var flash = require('connect-flash');
var methodOverride = require('method-override');
var models = require('./models/');
var passport = require('./middlewares/authentication');
var viewHelpers = require('./middlewares/viewHelpers');
var app = express();
app.use(methodOverride('_method'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(expressSession(({ secret: 'nyancat', resave: false, saveUninitialized: true, cookie: { maxAge: 1000*60*60*24 } })));
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static('./public'));
app.engine('handlebars', exphbs({
layoutsDir: './views/layouts',
partialsDir: './views/partials',
defaultLayout: 'main',
}));
app.set('view engine', 'handlebars');
app.set('views', `${__dirname}/views/`);
app.use(viewHelpers.register());
app.use(require('./controllers/'));
module.exports = app;
app.listen(8000);