Compose create layergroup middleware
This commit is contained in:
@@ -49,40 +49,15 @@ function MapController(prepareContext, pgConnection, templateMaps, mapBackend, m
|
||||
module.exports = MapController;
|
||||
|
||||
MapController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
this.prepareContext,
|
||||
createGetPrepareConfig,
|
||||
this.prepareAdapterMapConfig.bind(this),
|
||||
this.createLayergroup.bind(this),
|
||||
this.afterLayergroupCreateBuilder({
|
||||
includeQuery: true
|
||||
}),
|
||||
sendResponse,
|
||||
augmentError({
|
||||
label: 'ANONYMOUS LAYERGROUP',
|
||||
addContext: true
|
||||
})
|
||||
);
|
||||
app.post(
|
||||
app.base_url_mapconfig,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
this.prepareContext,
|
||||
createPostPrepareConfig,
|
||||
this.prepareAdapterMapConfig.bind(this),
|
||||
this.createLayergroup.bind(this),
|
||||
this.afterLayergroupCreateBuilder({
|
||||
includeQuery: true
|
||||
}),
|
||||
sendResponse,
|
||||
augmentError({
|
||||
label: 'ANONYMOUS LAYERGROUP',
|
||||
addContext: true
|
||||
})
|
||||
);
|
||||
app.get(app.base_url_mapconfig, this.composeCreateLayergroupMiddleware({
|
||||
includeQuery: true,
|
||||
parseConfigQueryParam: true
|
||||
}));
|
||||
|
||||
app.post(app.base_url_mapconfig, this.composeCreateLayergroupMiddleware({
|
||||
includeQuery: true
|
||||
}));
|
||||
|
||||
app.get(
|
||||
app.base_url_templated + '/:template_id/jsonp',
|
||||
cors(),
|
||||
@@ -118,8 +93,42 @@ MapController.prototype.register = function(app) {
|
||||
app.options(app.base_url_mapconfig, cors('Content-Type'));
|
||||
};
|
||||
|
||||
MapController.prototype.composeCreateLayergroupMiddleware = function (options) {
|
||||
const {
|
||||
parseConfigQueryParam = false,
|
||||
useTemplateHash = false,
|
||||
includeQuery = false
|
||||
} = options;
|
||||
|
||||
return [
|
||||
cors(),
|
||||
userMiddleware,
|
||||
this.prepareContext,
|
||||
parseConfigQueryParam ? createGetPrepareConfig : createPostPrepareConfig,
|
||||
this.prepareAdapterMapConfig.bind(this),
|
||||
this.createLayergroup.bind(this),
|
||||
this.incrementMapViewCount.bind(this),
|
||||
this.augmentLayergroupData.bind(this),
|
||||
this.getAffectedTables.bind(this),
|
||||
this.setCacheChannel.bind(this),
|
||||
this.setLastUpdatedTimeToLayergroup.bind(this),
|
||||
this.setCacheControl.bind(this),
|
||||
this.setLayerStats.bind(this),
|
||||
this.setLayergroupIdHeaderBuilder(useTemplateHash),
|
||||
this.setDataviewsAndWidgetsUrlsToLayergroupMetadata.bind(this),
|
||||
this.setAnalysesMetadataToLayergroupBuilder(includeQuery),
|
||||
this.setTurboCartoMetadataToLayergroup.bind(this),
|
||||
this.setSurrogateKeyHeader.bind(this),
|
||||
sendResponse,
|
||||
augmentError({
|
||||
label: 'ANONYMOUS LAYERGROUP',
|
||||
addContext: true
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
function createGetPrepareConfig (req, res, next) {
|
||||
req.profiler.start('windshaft.createmap_get');
|
||||
req.profiler.start(`windshaft.createmap_${req.method.toLowecase}`);
|
||||
|
||||
const { config } = res.locals;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user