Rename base paths

This commit is contained in:
Daniel García Aubert 2018-03-16 13:04:42 +01:00
parent 5ede6c3021
commit 071a5a4bdf
5 changed files with 32 additions and 28 deletions

View File

@ -16,8 +16,10 @@ function AnalysesController(pgConnection, authApi) {
module.exports = AnalysesController;
AnalysesController.prototype.register = function (app) {
const { base_url_mapconfig: mapconfigBasePath } = app;
app.get(
`${app.base_url_mapconfig}/analyses/catalog`,
`${mapconfigBasePath}/analyses/catalog`,
cors(),
userMiddleware(),
locals(),

View File

@ -53,10 +53,10 @@ function LayergroupController(pgConnection, mapStore, tileBackend, previewBacken
module.exports = LayergroupController;
LayergroupController.prototype.register = function(app) {
const { base_url_mapconfig: basePath } = app;
const { base_url_mapconfig: mapconfigBasePath } = app;
app.get(
`${basePath}/:token/:z/:x/:y@:scale_factor?x.:format`,
`${mapconfigBasePath}/:token/:z/:x/:y@:scale_factor?x.:format`,
cors(),
userMiddleware(),
locals(),
@ -80,7 +80,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/:z/:x/:y.:format`,
`${mapconfigBasePath}/:token/:z/:x/:y.:format`,
cors(),
userMiddleware(),
locals(),
@ -104,7 +104,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/:layer/:z/:x/:y.(:format)`,
`${mapconfigBasePath}/:token/:layer/:z/:x/:y.(:format)`,
distinguishLayergroupFromStaticRoute(),
cors(),
userMiddleware(),
@ -129,7 +129,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/:layer/attributes/:fid`,
`${mapconfigBasePath}/:token/:layer/attributes/:fid`,
cors(),
userMiddleware(),
locals(),
@ -151,7 +151,7 @@ LayergroupController.prototype.register = function(app) {
const forcedFormat = 'png';
app.get(
`${basePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`,
`${mapconfigBasePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`,
cors(),
userMiddleware(),
allowQueryParams(['layer']),
@ -172,7 +172,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`,
`${mapconfigBasePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`,
cors(),
userMiddleware(),
allowQueryParams(['layer']),
@ -211,7 +211,7 @@ LayergroupController.prototype.register = function(app) {
];
app.get(
`${basePath}/:token/dataview/:dataviewName`,
`${mapconfigBasePath}/:token/dataview/:dataviewName`,
cors(),
userMiddleware(),
allowQueryParams(allowedDataviewQueryParams),
@ -232,7 +232,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/:layer/widget/:dataviewName`,
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName`,
cors(),
userMiddleware(),
allowQueryParams(allowedDataviewQueryParams),
@ -253,7 +253,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/dataview/:dataviewName/search`,
`${mapconfigBasePath}/:token/dataview/:dataviewName/search`,
cors(),
userMiddleware(),
allowQueryParams(allowedDataviewQueryParams),
@ -274,7 +274,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/:layer/widget/:dataviewName/search`,
`${mapconfigBasePath}/:token/:layer/widget/:dataviewName/search`,
cors(),
userMiddleware(),
allowQueryParams(allowedDataviewQueryParams),
@ -295,7 +295,7 @@ LayergroupController.prototype.register = function(app) {
);
app.get(
`${basePath}/:token/analysis/node/:nodeId`,
`${mapconfigBasePath}/:token/analysis/node/:nodeId`,
cors(),
userMiddleware(),
locals(),

View File

@ -53,13 +53,15 @@ function MapController(pgConnection, templateMaps, mapBackend, metadataBackend,
module.exports = MapController;
MapController.prototype.register = function(app) {
const { base_url_mapconfig, base_url_templated } = app;
const { base_url_mapconfig: mapconfigBasePath, base_url_templated: templateBasePath } = app;
const useTemplate = true;
app.get(base_url_mapconfig, this.composeCreateMapMiddleware());
app.post(base_url_mapconfig, this.composeCreateMapMiddleware());
app.get(`${base_url_templated}/:template_id/jsonp`, this.composeCreateMapMiddleware(useTemplate));
app.post(`${base_url_templated}/:template_id`, this.composeCreateMapMiddleware(useTemplate));
app.get(mapconfigBasePath, this.composeCreateMapMiddleware());
app.post(mapconfigBasePath, this.composeCreateMapMiddleware());
app.get(`${templateBasePath}/:template_id/jsonp`, this.composeCreateMapMiddleware(useTemplate));
app.post(`${templateBasePath}/:template_id`, this.composeCreateMapMiddleware(useTemplate));
app.options(app.base_url_mapconfig, cors('Content-Type'));
};

View File

@ -48,10 +48,10 @@ function NamedMapsController(namedMapProviderCache, tileBackend, previewBackend,
module.exports = NamedMapsController;
NamedMapsController.prototype.register = function(app) {
const { base_url_mapconfig, base_url_templated } = app;
const { base_url_mapconfig: mapconfigBasePath, base_url_templated: templateBasePath } = app;
app.get(
`${base_url_templated}/:template_id/:layer/:z/:x/:y.(:format)`,
`${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`,
cors(),
userMiddleware(),
locals(),
@ -79,7 +79,7 @@ NamedMapsController.prototype.register = function(app) {
);
app.get(
`${base_url_mapconfig}/static/named/:template_id/:width/:height.:format`,
`${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`,
cors(),
userMiddleware(),
allowQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),

View File

@ -18,10 +18,10 @@ function NamedMapsAdminController(authApi, templateMaps) {
module.exports = NamedMapsAdminController;
NamedMapsAdminController.prototype.register = function (app) {
const { base_url_templated } = app;
const { base_url_templated: templateBasePath } = app;
app.post(
`${base_url_templated}/`,
`${templateBasePath}/`,
cors(),
userMiddleware(),
localsMiddleware(),
@ -33,7 +33,7 @@ NamedMapsAdminController.prototype.register = function (app) {
);
app.put(
`${base_url_templated}/:template_id`,
`${templateBasePath}/:template_id`,
cors(),
userMiddleware(),
localsMiddleware(),
@ -45,7 +45,7 @@ NamedMapsAdminController.prototype.register = function (app) {
);
app.get(
`${base_url_templated}/:template_id`,
`${templateBasePath}/:template_id`,
cors(),
userMiddleware(),
localsMiddleware(),
@ -56,7 +56,7 @@ NamedMapsAdminController.prototype.register = function (app) {
);
app.delete(
`${base_url_templated}/:template_id`,
`${templateBasePath}/:template_id`,
cors(),
userMiddleware(),
localsMiddleware(),
@ -67,7 +67,7 @@ NamedMapsAdminController.prototype.register = function (app) {
);
app.get(
`${base_url_templated}/`,
`${templateBasePath}/`,
cors(),
userMiddleware(),
localsMiddleware(),
@ -78,7 +78,7 @@ NamedMapsAdminController.prototype.register = function (app) {
);
app.options(
`${base_url_templated}/:template_id`,
`${templateBasePath}/:template_id`,
cors('Content-Type')
);
};