-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·36 lines (32 loc) · 1.28 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
/*
salesman main server file
*/
var express = require('express');
var app = module.exports = express();
var http = require('http');
var path = require('path');
var bodyParser = require('body-parser');
app.locals.bunyan = require('bunyan');
app.locals.config = require('config'); // set config to locals, read from config/default.js
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var log = app.locals.bunyan.createLogger({name: 'server'});
app.use(express.static(path.join(__dirname, 'public'))); // only public directory will be serve static content
// TODO: fix views forr angular
app.set('views', __dirname + '/public/app/views');
app.set('view engine', 'html');
//app.enable('view cache');
app.engine('html', require('hogan-express'));
// initialization
require('./config/init/aws')(app);
require('./config/init/semantics')(app);
require('./config/init/cache')(app);
require('./config/init/utils')(app);
require('./config/init/errors')(app);
require('./config/init/routes')(app);
require('./config/init/db')(app);
require('./config/init/categories')(app);
// application server start
server = http.createServer(app);
server.listen(app.locals.config.server.port, app.locals.config.server.ip);
log.info("Salesman Server listening on port " + app.locals.config.server.port);