-
Notifications
You must be signed in to change notification settings - Fork 7
/
server.js
35 lines (26 loc) · 1.22 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
var express = require('express');
var logger = require('morgan');
var bodyParser = require('body-parser');
var exphbs = require('express-handlebars');
var helmet = require('helmet');
var app = express();
var server = require('http').Server(app);
//setup security ===============================================================
require('./app/shared/security-setup')(app, helmet);
// configuration ===============================================================
app.use(logger('dev')); // log every request to the console
// set up our express application ==============================================
// Make the body object available on the request
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// set handlebars as default templating engine
app.engine('handlebars', exphbs({defaultLayout: 'layout'}));
app.set('view engine', 'handlebars');
// serve the static content
app.use(express.static(__dirname + '/public'));
// mount the routes
require('./app/routes.js')(app); // load our routes and pass in our app
// errorhandling
require('./app/shared/errorhandling.js')(app);
// export so bin/www can launch ================================================
module.exports = {app: app, server: server};