diff --git a/lib/cartodb/server.js b/lib/cartodb/server.js index 6ff59abf..3645fa1a 100644 --- a/lib/cartodb/server.js +++ b/lib/cartodb/server.js @@ -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;