-
Notifications
You must be signed in to change notification settings - Fork 12
/
app.js
67 lines (48 loc) · 1.32 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
const path = require('path');
const express = require('express');
const app = express();
const hbs = require('hbs');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const viewsDir = path.join(__dirname, 'bundles');
const publicDir = path.join(__dirname, 'public');
const passport = require('./lib/passport');
app.set('views', viewsDir);
app.set('view engine', 'hbs');
app.use(morgan('dev'));
app.use(express.static(publicDir));
app.set('port', (process.env.PORT || 5000));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
/* eslint max-params: [2, 4] */
app.use((err, req, res, next) => {
console.error(err);
next();
});
app.use(require('express-session')({
secret: 'kotik',
resave: false,
saveUninitialized: false
}));
app.use(passport.initUser);
app.use((req, res, next) => {
req.commonData = {
meta: {
description: 'Awesome notes',
charset: 'utf-8'
},
page: {
title: 'Awesome notes'
},
isDev: process.env.NODE_ENV === 'development'
};
next();
});
require('./routes')(app);
hbs.registerPartials(path.join(__dirname, 'blocks'));
app.listen(app.get('port'),
() => console.log(`Listening on port ${app.get('port')}`));
module.exports = app;