Do not use locals middleware in named maps controller
This commit is contained in:
parent
f7a23c094c
commit
5fc801f8a6
@ -1,6 +1,5 @@
|
|||||||
const cors = require('../middleware/cors');
|
const cors = require('../middleware/cors');
|
||||||
const user = require('../middleware/user');
|
const user = require('../middleware/user');
|
||||||
const locals = require('../middleware/locals');
|
|
||||||
const cleanUpQueryParams = require('../middleware/clean-up-query-params');
|
const cleanUpQueryParams = require('../middleware/clean-up-query-params');
|
||||||
const layergroupToken = require('../middleware/layergroup-token');
|
const layergroupToken = require('../middleware/layergroup-token');
|
||||||
const credentials = require('../middleware/credentials');
|
const credentials = require('../middleware/credentials');
|
||||||
@ -58,7 +57,6 @@ NamedMapsController.prototype.register = function(app) {
|
|||||||
`${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`,
|
`${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`,
|
||||||
cors(),
|
cors(),
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
locals(),
|
|
||||||
user(),
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_TILES),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_TILES),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
@ -86,7 +84,6 @@ NamedMapsController.prototype.register = function(app) {
|
|||||||
`${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`,
|
`${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
||||||
locals(),
|
|
||||||
user(),
|
user(),
|
||||||
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC_NAMED),
|
rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC_NAMED),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
@ -215,9 +212,11 @@ function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label })
|
|||||||
|
|
||||||
function getTile ({ tileBackend, label }) {
|
function getTile ({ tileBackend, label }) {
|
||||||
return function getTileMiddleware (req, res, next) {
|
return function getTileMiddleware (req, res, next) {
|
||||||
const { mapConfigProvider, format } = res.locals;
|
const { mapConfigProvider } = res.locals;
|
||||||
|
const { layer, z, x, y, format } = req.params;
|
||||||
|
const params = { layer, z, x, y, format };
|
||||||
|
|
||||||
tileBackend.getTile(mapConfigProvider, req.params, (err, tile, headers, stats) => {
|
tileBackend.getTile(mapConfigProvider, params, (err, tile, headers, stats) => {
|
||||||
req.profiler.add(stats);
|
req.profiler.add(stats);
|
||||||
req.profiler.done('render-' + format);
|
req.profiler.done('render-' + format);
|
||||||
|
|
||||||
@ -240,8 +239,10 @@ function getTile ({ tileBackend, label }) {
|
|||||||
function getStaticImageOptions ({ tablesExtentApi }) {
|
function getStaticImageOptions ({ tablesExtentApi }) {
|
||||||
return function getStaticImageOptionsMiddleware(req, res, next) {
|
return function getStaticImageOptionsMiddleware(req, res, next) {
|
||||||
const { user, mapConfigProvider, template } = res.locals;
|
const { user, mapConfigProvider, template } = res.locals;
|
||||||
|
const { zoom, lon, lat, bbox } = req.query;
|
||||||
|
const params = { zoom, lon, lat, bbox };
|
||||||
|
|
||||||
const imageOpts = getImageOptions(res.locals, template);
|
const imageOpts = getImageOptions(params, template);
|
||||||
|
|
||||||
if (imageOpts) {
|
if (imageOpts) {
|
||||||
res.locals.imageOpts = imageOpts;
|
res.locals.imageOpts = imageOpts;
|
||||||
|
Loading…
Reference in New Issue
Block a user