Reorder middlewares to optimize workflow
This commit is contained in:
parent
67d2d2fe95
commit
639a69a639
@ -21,9 +21,9 @@ AnalysesController.prototype.register = function (app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/analyses/catalog`,
|
`${mapconfigBasePath}/analyses/catalog`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
|
@ -57,9 +57,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/:z/:x/:y@:scale_factor?x.:format`,
|
`${mapconfigBasePath}/:token/:z/:x/:y@:scale_factor?x.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -81,9 +81,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/:z/:x/:y.:format`,
|
`${mapconfigBasePath}/:token/:z/:x/:y.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -106,9 +106,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
`${mapconfigBasePath}/:token/:layer/:z/:x/:y.(:format)`,
|
`${mapconfigBasePath}/:token/:layer/:z/:x/:y.(:format)`,
|
||||||
distinguishLayergroupFromStaticRoute(),
|
distinguishLayergroupFromStaticRoute(),
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -130,9 +130,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/:layer/attributes/:fid`,
|
`${mapconfigBasePath}/:token/:layer/attributes/:fid`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -152,9 +152,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`,
|
`${mapconfigBasePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(['layer']),
|
cleanUpQueryParams(['layer']),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -172,9 +172,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`,
|
`${mapconfigBasePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(['layer']),
|
cleanUpQueryParams(['layer']),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -210,9 +210,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/dataview/:dataviewName`,
|
`${mapconfigBasePath}/:token/dataview/:dataviewName`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(allowedDataviewQueryParams),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -230,9 +230,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName`,
|
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(allowedDataviewQueryParams),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -250,9 +250,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/dataview/:dataviewName/search`,
|
`${mapconfigBasePath}/:token/dataview/:dataviewName/search`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(allowedDataviewQueryParams),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -270,9 +270,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName/search`,
|
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName/search`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(allowedDataviewQueryParams),
|
cleanUpQueryParams(allowedDataviewQueryParams),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -290,9 +290,9 @@ LayergroupController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/:token/analysis/node/:nodeId`,
|
`${mapconfigBasePath}/:token/analysis/node/:nodeId`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
|
@ -73,9 +73,9 @@ MapController.prototype.composeCreateMapMiddleware = function (useTemplate = fal
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(['aggregation']),
|
cleanUpQueryParams(['aggregation']),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
|
@ -52,9 +52,9 @@ NamedMapsController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`,
|
`${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(),
|
cleanUpQueryParams(),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
@ -80,9 +80,9 @@ NamedMapsController.prototype.register = function(app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`,
|
`${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
locals(),
|
|
||||||
cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
||||||
|
locals(),
|
||||||
|
userMiddleware(),
|
||||||
layergroupToken(),
|
layergroupToken(),
|
||||||
credentials(),
|
credentials(),
|
||||||
authorize(this.authApi),
|
authorize(this.authApi),
|
||||||
|
@ -23,8 +23,8 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
app.post(
|
app.post(
|
||||||
`${templateBasePath}/`,
|
`${templateBasePath}/`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
localsMiddleware(),
|
localsMiddleware(),
|
||||||
|
userMiddleware(),
|
||||||
credentialsMiddleware(),
|
credentialsMiddleware(),
|
||||||
checkContentType({ action: 'POST', label: 'POST TEMPLATE' }),
|
checkContentType({ action: 'POST', label: 'POST TEMPLATE' }),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'create', label: 'POST TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'create', label: 'POST TEMPLATE' }),
|
||||||
@ -35,8 +35,8 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
app.put(
|
app.put(
|
||||||
`${templateBasePath}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
localsMiddleware(),
|
localsMiddleware(),
|
||||||
|
userMiddleware(),
|
||||||
credentialsMiddleware(),
|
credentialsMiddleware(),
|
||||||
checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }),
|
checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'update', label: 'PUT TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'update', label: 'PUT TEMPLATE' }),
|
||||||
@ -47,8 +47,8 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${templateBasePath}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
localsMiddleware(),
|
localsMiddleware(),
|
||||||
|
userMiddleware(),
|
||||||
credentialsMiddleware(),
|
credentialsMiddleware(),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'get', label: 'GET TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'get', label: 'GET TEMPLATE' }),
|
||||||
retrieveTemplate({ templateMaps: this.templateMaps }),
|
retrieveTemplate({ templateMaps: this.templateMaps }),
|
||||||
@ -58,8 +58,8 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
app.delete(
|
app.delete(
|
||||||
`${templateBasePath}/:template_id`,
|
`${templateBasePath}/:template_id`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
localsMiddleware(),
|
localsMiddleware(),
|
||||||
|
userMiddleware(),
|
||||||
credentialsMiddleware(),
|
credentialsMiddleware(),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'delete', label: 'DELETE TEMPLATE' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'delete', label: 'DELETE TEMPLATE' }),
|
||||||
destroyTemplate({ templateMaps: this.templateMaps }),
|
destroyTemplate({ templateMaps: this.templateMaps }),
|
||||||
@ -69,8 +69,8 @@ NamedMapsAdminController.prototype.register = function (app) {
|
|||||||
app.get(
|
app.get(
|
||||||
`${templateBasePath}/`,
|
`${templateBasePath}/`,
|
||||||
cors(),
|
cors(),
|
||||||
userMiddleware(),
|
|
||||||
localsMiddleware(),
|
localsMiddleware(),
|
||||||
|
userMiddleware(),
|
||||||
credentialsMiddleware(),
|
credentialsMiddleware(),
|
||||||
authorizedByAPIKey({ authApi: this.authApi, action: 'list', label: 'GET TEMPLATE LIST' }),
|
authorizedByAPIKey({ authApi: this.authApi, action: 'list', label: 'GET TEMPLATE LIST' }),
|
||||||
listTemplates({ templateMaps: this.templateMaps }),
|
listTemplates({ templateMaps: this.templateMaps }),
|
||||||
|
@ -24,9 +24,6 @@ module.exports = function cleanUpQueryParamsMiddleware (customQueryParams = [])
|
|||||||
|
|
||||||
req.query = _.pick(req.query, allowedQueryParams);
|
req.query = _.pick(req.query, allowedQueryParams);
|
||||||
|
|
||||||
// bring all query values onto res.locals object
|
|
||||||
_.extend(res.locals, req.query);
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module.exports = function locals () {
|
module.exports = function locals () {
|
||||||
return function localsMiddleware (req, res, next) {
|
return function localsMiddleware (req, res, next) {
|
||||||
res.locals = Object.assign(req.params || {}, res.locals);
|
res.locals = Object.assign({}, req.query, req.params);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user