-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
57 lines (46 loc) · 1.56 KB
/
server.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
'use strict';
var express = require('express');
var session = require('express-session');
var path = require('path');
var favicon = require('serve-favicon');
var morgan = require('morgan');
var bodyParser = require('body-parser');
var errorHandler = require('./core/errorHandler');
var app = express();
var api = require('./api/_initializer.js');
var webApp = require('./app/_initializer.js');
var keyContext = require('./data/secrets/context')();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
// Opt into Services
//https://github.com/expressjs/morgan
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({
secret: 'quoh8ukaechooBiong2eexeewa6pheuquengeiyedailae9EethohmeuDiecie5ahb2cat', resave: true,
saveUninitialized: true
}));
app.middlewares = {};
app.middlewares.passportTequila = require('./core/security/tequilaConfig')(app),
app.middlewares.roles = require('./core/security/roles')(app)
keyContext.loadKeys();
app.keyContext = keyContext;
// set the public static resource folder
app.use(express.static(__dirname + '/public'));
app.use(favicon(__dirname + '/public/favicon.ico'));
//Map the routes
api.init(app);
webApp.init(app);
app.get('/', function (req, res) {
res.render('homepage');
});
app.get('/api/pomme', function (req, res) {
res.render('pomme');
})
//TODO: Enable and Refine the errorHanlder
app.use(errorHandler);
app.listen(process.env.PORT || 3000);
console.log('Listening on port 3000...');
module.exports = app;