-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
40 lines (31 loc) · 1.1 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
'use strict';
console.log('\n\nEnvironment variables:\n', process.env);
console.log('\n\n');
require('rootpath')();
// node modules
var util = require('util');
var logger = require('server/core/logger').file('./app.js');
var path = require('path');
var _ = require('lodash');
// basic middleware modules
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
// require express framework & launch the application
var app = require('express')();
// add app config to the express app object
app.locals.config = require('config');
logger.debug(app.locals.config);
// app.use('/api', require('server/serve-rest-api')),
// consume & initialize basic middleware
app.use(bodyParser.raw());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// consume the subcomponents of the app
app = _.flow(
require('server/serve-rest-api'),
require('server/serve-static')
// ,
// require('server/serve-admin') // serve-admin must always go last
)(app);
// listen for requests on port 3000
app.listen(process.env.PORT || _.get(app.locals.config.get('server'), 'port') || 3000);