-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
53 lines (43 loc) · 1.42 KB
/
index.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
var express = require('express');
var session = require('express-session');
var bodyParser = require('body-parser');
var compress = require('compression');
var glob = require('glob');
var passport = require('passport');
var Sequelize = require('sequelize');
var SequelizeStore = require('connect-sequelize')(session);
var cookieParser = require('cookie-parser');
var config = require('./config/config');
var logger = require('./app/util/logger');
(function() {
'use strict';
var app = express();
var db = new Sequelize(config.mysql.database, config.mysql.user,
config.mysql.pass, { logging: false });
// session store
app.use(cookieParser());
app.use(session(
{
secret: config.session.secret,
resave: false,
saveUninitialized: false,
store: new SequelizeStore(db, {}, 'user_sessions')
}
));
app.use(passport.initialize());
app.use(passport.session());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(compress());
app.use(express.static(config.root + '/public'));
var routers = glob.sync(config.root + '/app/routers/*.js');
routers.forEach(function(router) {
/* eslint-disable global-require */
require(router)(app);
/* eslint-enable */
});
app.listen(config.port);
logger.info('Server listening on port', config.port);
}());