obrand-admin-server/O-BrandServer/obrand-server.js
2016-04-22 16:45:04 +01:00

70 lines
1.9 KiB
JavaScript

/**
*
* User: Martin Donnelly
* Date: 2016-03-31
* Time: 09:44
*
*/
var express = require('express'), path = require('path'), http = require('http');
var session = require('session');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
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'}));
app.use(cookieParser('!n87klqX39cB:7ayiRzEL5yRy5y938'));
/*app.use(session({
secret: 'G)+W&2W5C3V6gXJ.8mSD!l/-n3D]EV', resave: false,
saveUninitialized: false
}));*/
app.use('/export',express.static(path.join(__dirname,'server/static')));
app.use('/css',express.static(path.join(__dirname,'server/css')));
app.use('/',express.static(path.join(__dirname,'wwwroot')));
/* These next app.get's deal with ember's routing and when the user refreshes
the page. It forces the page back into the app.
*/
app.get('/about', function(request, response) {
response.redirect('/#/about');
});
app.get('/profile', function(request, response) {
response.redirect('/#/profile');
});
app.get('/company', function(request, response) {
response.redirect('/#/company');
});
app.get('/venue', function(request, response) {
response.redirect('/#/venue');
});
app.get('/pages', function(request, response) {
response.redirect('/#/pages');
});
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')));
});