Windshaft-cartodb/lib/server.js
Daniel García Aubert a8fb51ba25 - Rename NamedMapProviderReporter by NamedMapProviderCacheReporter
- Extract getOnTileErrorStrategy to a module
- Stop using MapStore from windshaft while testing and create a custom one instead
2020-04-04 17:46:08 +02:00

33 lines
1.0 KiB
JavaScript

'use strict';
const express = require('express');
const jsonReplacer = require('./utils/json-replacer');
const ApiRouter = require('./api/api-router');
const ServerInfoController = require('./server-info-controller');
const StatsClient = require('./stats/client');
module.exports = function createServer (serverOptions) {
if (!Object.prototype.hasOwnProperty.call(serverOptions, 'routes')) {
throw new Error('Must initialise server with "routes" as base paths configuration');
}
// Make stats client globally accessible
global.statsClient = StatsClient.getInstance(serverOptions.statsd);
const app = express();
app.enable('jsonp callback');
app.disable('x-powered-by');
app.disable('etag');
app.set('json replacer', jsonReplacer());
const apiRouter = new ApiRouter({ serverOptions, environmentOptions: global.environment });
apiRouter.route(app, serverOptions.routes.api);
const serverInfoController = new ServerInfoController();
serverInfoController.route(app);
return app;
};