Reorg requires
This commit is contained in:
parent
2d3f2667ca
commit
a6017c6ade
@ -1,15 +1,12 @@
|
||||
var assert = require('assert');
|
||||
|
||||
var express = require('express');
|
||||
|
||||
var RedisPool = require('redis-mpool');
|
||||
var _ = require('underscore');
|
||||
|
||||
|
||||
var step = require('step');
|
||||
|
||||
|
||||
var HealthCheck = require('./monitoring/health_check');
|
||||
|
||||
|
||||
var StaticMapsController = require('./controllers/static_maps');
|
||||
var MapController = require('./controllers/map');
|
||||
|
||||
@ -126,7 +123,8 @@ module.exports = function(serverOptions) {
|
||||
|
||||
// initialize express server
|
||||
var app = bootstrap(serverOptions);
|
||||
addFilters(app, serverOptions);
|
||||
// Extend windshaft with all the elements of the options object
|
||||
_.extend(app, serverOptions);
|
||||
|
||||
var map_store = new windshaft.storage.MapStore({
|
||||
pool: redisPool,
|
||||
@ -396,7 +394,7 @@ module.exports = function(serverOptions) {
|
||||
|
||||
app.getVersion = function() {
|
||||
return {
|
||||
windshaft: require('../../package.json').version,
|
||||
windshaft: windshaft.version,
|
||||
grainstore: grainstore.version(),
|
||||
node_mapnik: mapnik.version,
|
||||
mapnik: mapnik.versions.mapnik,
|
||||
@ -930,7 +928,16 @@ module.exports = function(serverOptions) {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
app.doCORS = function(res, extraHeaders) {
|
||||
if (serverOptions.enable_cors) {
|
||||
var baseHeaders = "X-Requested-With, X-Prototype-Version, X-CSRF-Token";
|
||||
if(extraHeaders) {
|
||||
baseHeaders += ", " + extraHeaders;
|
||||
}
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", baseHeaders);
|
||||
}
|
||||
};
|
||||
|
||||
return app;
|
||||
};
|
||||
@ -1015,28 +1022,6 @@ function setupLogger(app, opts) {
|
||||
}
|
||||
}
|
||||
|
||||
// set default before/after filters if not set in opts object
|
||||
function addFilters(app, opts) {
|
||||
|
||||
// Extend windshaft with all the elements of the options object
|
||||
_.extend(app, opts);
|
||||
|
||||
// filters can be used for custom authentication, caching, logging etc
|
||||
_.defaults(app, {
|
||||
// Enable CORS access by web browsers if set
|
||||
doCORS: function(res, extraHeaders) {
|
||||
if (opts.enable_cors) {
|
||||
var baseHeaders = "X-Requested-With, X-Prototype-Version, X-CSRF-Token";
|
||||
if(extraHeaders) {
|
||||
baseHeaders += ", " + extraHeaders;
|
||||
}
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", baseHeaders);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function statusFromErrorMessage(errMsg) {
|
||||
// Find an appropriate statusCode based on message
|
||||
var statusCode = 400;
|
||||
|
Loading…
Reference in New Issue
Block a user