2016-03-31 13:24:21 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* User: Martin Donnelly
|
|
|
|
* Date: 2016-03-31
|
|
|
|
* Time: 09:44
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var express = require('express'), path = require('path'), http = require('http');
|
2016-04-04 08:59:37 +00:00
|
|
|
var session = require('session');
|
2016-03-31 13:24:21 +00:00
|
|
|
var morgan = require('morgan');
|
|
|
|
var cookieParser = require('cookie-parser');
|
|
|
|
var bodyParser = require('body-parser');
|
2016-04-04 11:52:15 +00:00
|
|
|
var session = require('session');
|
2016-03-31 13:24:21 +00:00
|
|
|
var globSync = require('glob').sync;
|
|
|
|
var colors = require('colors/safe');
|
|
|
|
|
|
|
|
|
|
|
|
var app = express();
|
|
|
|
|
|
|
|
app.set('port', process.env.PORT || 8086);
|
|
|
|
app.set('views', path.join(__dirname, 'views'));
|
|
|
|
app.set('view engine', 'jade');
|
|
|
|
app.use(morgan('dev'));
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(bodyParser.json({type: 'application/vnd.api+json'}));
|
2016-04-04 08:59:37 +00:00
|
|
|
app.use(cookieParser('!n87klqX39cB:7ayiRzEL5yRy5y938'));
|
|
|
|
app.use(session({
|
|
|
|
secret: 'G)+W&2W5C3V6gXJ.8mSD!l/-n3D]EV', resave: false,
|
|
|
|
saveUninitialized: false
|
|
|
|
}));
|
2016-03-31 13:24:21 +00:00
|
|
|
app.use('/export',express.static(path.join(__dirname,'server/static')));
|
|
|
|
app.use('/css',express.static(path.join(__dirname,'server/css')));
|
2016-04-04 08:59:37 +00:00
|
|
|
app.use('/',express.static(path.join(__dirname,'wwwroot')));
|
2016-03-31 13:24:21 +00:00
|
|
|
|
|
|
|
console.log(path.join(__dirname,'server/static'));
|
|
|
|
|
|
|
|
var backend = globSync('./server/app/**/*.js', { cwd: __dirname }).map(require);
|
|
|
|
|
|
|
|
backend.forEach(function(route) { route(app); });
|
|
|
|
|
|
|
|
|
|
|
|
app.listen(app.get('port'), function() {
|
|
|
|
'use strict';
|
|
|
|
console.log(colors.magenta('Obrand Server listening on ' + app.get('port')));
|
|
|
|
});
|