Create layergroup controllers in server construction
This commit is contained in:
parent
51fade6bd3
commit
57e10a8d2b
@ -1,6 +1,5 @@
|
||||
module.exports = {
|
||||
Analyses: require('./analyses'),
|
||||
Layergroup: require('./layergroup'),
|
||||
Map: require('./map'),
|
||||
ServerInfo: require('./server_info')
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
|
||||
const sendResponse = require('../../middleware/send-response');
|
||||
const dbParamsFromResLocals = require('../../utils/database-params');
|
||||
|
||||
module.exports = class AnalysisController {
|
||||
module.exports = class AnalysisLayergroupController {
|
||||
constructor (
|
||||
analysisStatusBackend,
|
||||
pgConnection,
|
||||
|
@ -12,7 +12,7 @@ const surrogateKeyHeader = require('../../middleware/surrogate-key-header');
|
||||
const lastModifiedHeader = require('../../middleware/last-modified-header');
|
||||
const sendResponse = require('../../middleware/send-response');
|
||||
|
||||
module.exports = class AttributesController {
|
||||
module.exports = class AttributesLayergroupController {
|
||||
constructor (
|
||||
attributesBackend,
|
||||
pgConnection,
|
||||
|
@ -27,7 +27,7 @@ const ALLOWED_DATAVIEW_QUERY_PARAMS = [
|
||||
'categories', // number
|
||||
];
|
||||
|
||||
module.exports = class DataviewController {
|
||||
module.exports = class DataviewLayergroupController {
|
||||
constructor (
|
||||
dataviewBackend,
|
||||
pgConnection,
|
||||
|
@ -1,112 +0,0 @@
|
||||
const DataviewBackend = require('../../backends/dataview');
|
||||
const AnalysisStatusBackend = require('../../backends/analysis-status');
|
||||
|
||||
const TileController = require('./tile');
|
||||
const AttributesController = require('./attributes');
|
||||
const StaticController = require('./static');
|
||||
const DataviewController = require('./dataview');
|
||||
const AnalysisController = require('./analysis');
|
||||
|
||||
/**
|
||||
* @param {prepareContext} prepareContext
|
||||
* @param {PgConnection} pgConnection
|
||||
* @param {MapStore} mapStore
|
||||
* @param {TileBackend} tileBackend
|
||||
* @param {PreviewBackend} previewBackend
|
||||
* @param {AttributesBackend} attributesBackend
|
||||
* @param {SurrogateKeysCache} surrogateKeysCache
|
||||
* @param {UserLimitsApi} userLimitsApi
|
||||
* @param {LayergroupAffectedTables} layergroupAffectedTables
|
||||
* @param {AnalysisBackend} analysisBackend
|
||||
* @constructor
|
||||
*/
|
||||
function LayergroupController(
|
||||
pgConnection,
|
||||
mapStore,
|
||||
tileBackend,
|
||||
previewBackend,
|
||||
attributesBackend,
|
||||
surrogateKeysCache,
|
||||
userLimitsApi,
|
||||
layergroupAffectedTablesCache,
|
||||
analysisBackend,
|
||||
authApi
|
||||
) {
|
||||
this.pgConnection = pgConnection;
|
||||
this.mapStore = mapStore;
|
||||
this.tileBackend = tileBackend;
|
||||
this.previewBackend = previewBackend;
|
||||
this.attributesBackend = attributesBackend;
|
||||
this.surrogateKeysCache = surrogateKeysCache;
|
||||
this.userLimitsApi = userLimitsApi;
|
||||
this.layergroupAffectedTablesCache = layergroupAffectedTablesCache;
|
||||
|
||||
this.dataviewBackend = new DataviewBackend(analysisBackend);
|
||||
this.analysisStatusBackend = new AnalysisStatusBackend();
|
||||
this.authApi = authApi;
|
||||
}
|
||||
|
||||
module.exports = LayergroupController;
|
||||
|
||||
LayergroupController.prototype.register = function(app) {
|
||||
|
||||
const tileController = new TileController(
|
||||
this.tileBackend,
|
||||
this.pgConnection,
|
||||
this.mapStore,
|
||||
this.userLimitsApi,
|
||||
this.layergroupAffectedTablesCache,
|
||||
this.authApi,
|
||||
this.surrogateKeysCache
|
||||
);
|
||||
|
||||
tileController.register(app);
|
||||
|
||||
const attributesController = new AttributesController(
|
||||
this.attributesBackend,
|
||||
this.pgConnection,
|
||||
this.mapStore,
|
||||
this.userLimitsApi,
|
||||
this.layergroupAffectedTablesCache,
|
||||
this.authApi,
|
||||
this.surrogateKeysCache
|
||||
);
|
||||
|
||||
attributesController.register(app);
|
||||
|
||||
const staticController = new StaticController(
|
||||
this.previewBackend,
|
||||
this.pgConnection,
|
||||
this.mapStore,
|
||||
this.userLimitsApi,
|
||||
this.layergroupAffectedTablesCache,
|
||||
this.authApi,
|
||||
this.surrogateKeysCache
|
||||
);
|
||||
|
||||
staticController.register(app);
|
||||
|
||||
const dataviewController = new DataviewController(
|
||||
this.dataviewBackend,
|
||||
this.pgConnection,
|
||||
this.mapStore,
|
||||
this.userLimitsApi,
|
||||
this.layergroupAffectedTablesCache,
|
||||
this.authApi,
|
||||
this.surrogateKeysCache
|
||||
);
|
||||
|
||||
dataviewController.register(app);
|
||||
|
||||
const analysisController = new AnalysisController(
|
||||
this.analysisStatusBackend,
|
||||
this.pgConnection,
|
||||
this.mapStore,
|
||||
this.userLimitsApi,
|
||||
this.layergroupAffectedTablesCache,
|
||||
this.authApi,
|
||||
this.surrogateKeysCache
|
||||
);
|
||||
|
||||
analysisController.register(app);
|
||||
};
|
@ -12,7 +12,7 @@ const surrogateKeyHeader = require('../../middleware/surrogate-key-header');
|
||||
const lastModifiedHeader = require('../../middleware/last-modified-header');
|
||||
const sendResponse = require('../../middleware/send-response');
|
||||
|
||||
module.exports = class StaticController {
|
||||
module.exports = class PreviewLayergroupController {
|
||||
constructor (
|
||||
previewBackend,
|
||||
pgConnection,
|
@ -22,7 +22,7 @@ const SUPPORTED_FORMATS = {
|
||||
mvt: true
|
||||
};
|
||||
|
||||
module.exports = class TileController {
|
||||
module.exports = class TileLayergroupController {
|
||||
constructor (
|
||||
tileBackend,
|
||||
pgConnection,
|
||||
|
@ -7,6 +7,12 @@ var cartodbRedis = require('cartodb-redis');
|
||||
var _ = require('underscore');
|
||||
|
||||
var controller = require('./controllers');
|
||||
const AnalysisLayergroupController = require('./controllers/layergroup/analysis');
|
||||
const AttributesLayergroupController = require('./controllers/layergroup/attributes');
|
||||
const DataviewLayergroupController = require('./controllers/layergroup/dataview');
|
||||
const PreviewLayergroupController = require('./controllers/layergroup/preview');
|
||||
const TileLayergroupController = require('./controllers/layergroup/tile');
|
||||
|
||||
const AdminTemplateController = require('./controllers/template/admin');
|
||||
const PreviewTemplateController = require('./controllers/template/preview');
|
||||
const TileTemplateController = require('./controllers/template/tile');
|
||||
@ -35,6 +41,8 @@ var PgQueryRunner = require('./backends/pg_query_runner');
|
||||
var PgConnection = require('./backends/pg_connection');
|
||||
|
||||
var AnalysisBackend = require('./backends/analysis');
|
||||
const AnalysisStatusBackend = require('./backends/analysis-status');
|
||||
const DataviewBackend = require('./backends/dataview');
|
||||
|
||||
var timeoutErrorTilePath = __dirname + '/../../assets/render-timeout-fallback.png';
|
||||
var timeoutErrorTile = require('fs').readFileSync(timeoutErrorTilePath, {encoding: null});
|
||||
@ -182,6 +190,9 @@ module.exports = function(serverOptions) {
|
||||
var mapBackend = new windshaft.backend.Map(rendererCache, mapStore, mapValidatorBackend);
|
||||
|
||||
var analysisBackend = new AnalysisBackend(metadataBackend, serverOptions.analysis);
|
||||
const analysisStatusBackend = new AnalysisStatusBackend();
|
||||
|
||||
const dataviewBackend = new DataviewBackend(analysisBackend);
|
||||
|
||||
var statsBackend = new StatsBackend();
|
||||
|
||||
@ -227,17 +238,54 @@ module.exports = function(serverOptions) {
|
||||
const templateRouter = express.Router();
|
||||
const monitorRouter = express.Router();
|
||||
|
||||
new controller.Layergroup(
|
||||
new AnalysisLayergroupController(
|
||||
analysisStatusBackend,
|
||||
pgConnection,
|
||||
mapStore,
|
||||
tileBackend,
|
||||
previewBackend,
|
||||
attributesBackend,
|
||||
surrogateKeysCache,
|
||||
userLimitsApi,
|
||||
layergroupAffectedTablesCache,
|
||||
analysisBackend,
|
||||
authApi
|
||||
authApi,
|
||||
surrogateKeysCache
|
||||
).register(mapRouter);
|
||||
|
||||
new AttributesLayergroupController(
|
||||
attributesBackend,
|
||||
pgConnection,
|
||||
mapStore,
|
||||
userLimitsApi,
|
||||
layergroupAffectedTablesCache,
|
||||
authApi,
|
||||
surrogateKeysCache
|
||||
).register(mapRouter);
|
||||
|
||||
new DataviewLayergroupController(
|
||||
dataviewBackend,
|
||||
pgConnection,
|
||||
mapStore,
|
||||
userLimitsApi,
|
||||
layergroupAffectedTablesCache,
|
||||
authApi,
|
||||
surrogateKeysCache
|
||||
).register(mapRouter);
|
||||
|
||||
new PreviewLayergroupController(
|
||||
previewBackend,
|
||||
pgConnection,
|
||||
mapStore,
|
||||
userLimitsApi,
|
||||
layergroupAffectedTablesCache,
|
||||
authApi,
|
||||
surrogateKeysCache
|
||||
).register(mapRouter);
|
||||
|
||||
new TileLayergroupController(
|
||||
tileBackend,
|
||||
pgConnection,
|
||||
mapStore,
|
||||
userLimitsApi,
|
||||
layergroupAffectedTablesCache,
|
||||
authApi,
|
||||
surrogateKeysCache
|
||||
).register(mapRouter);
|
||||
|
||||
new controller.Map(
|
||||
|
Loading…
Reference in New Issue
Block a user