forked from dtpublic/malhar-dashboard-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (32 loc) · 1.17 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
41
var express = require('express');
var http = require('http');
var config = require('./config');
var app = express();
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
};
// all environments
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(allowCrossDomain);
app.use(app.router);
console.log('environment: ' + app.get('env'));
app.use(express.static(__dirname + config.staticDir));
if ('development' === app.get('env')) {
app.use(express.errorHandler());
}
app.get('/settings.js', function(req, res) {
res.setHeader('Content-Type', 'application/javascript');
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', 0);
res.send('window.settings = ' + JSON.stringify(config.settings) + ';');
});
http.createServer(app).listen(config.port, function(){
console.log('Express server listening on port ' + config.port);
});