Keep the backwards compatibility for routing configuration

This commit is contained in:
Daniel García Aubert 2019-10-06 18:58:21 +02:00
parent 4aa6ffe28c
commit 43a63feaca
4 changed files with 38 additions and 38 deletions

View File

@ -202,11 +202,6 @@ module.exports = class ApiRouter {
app.layergroupAffectedTablesCache = this.layergroupAffectedTablesCache;
}
// TODO: remove it before releasing next major version
if (!Array.isArray(routes)) {
routes = [ routes ];
}
routes.forEach(route => {
const apiRouter = router({ mergeParams: true });
const { paths, middlewares = [] } = route;

View File

@ -129,11 +129,6 @@ module.exports = class MapRouter {
route (apiRouter, routes) {
const mapRouter = router({ mergeParams: true });
// TODO: remove it before releasing next major version
if (!Array.isArray(routes)) {
routes = [ routes ];
}
routes.forEach(route => {
const { paths, middlewares = [] } = route;

View File

@ -57,12 +57,6 @@ module.exports = class TemplateRouter {
route (apiRouter, routes) {
const templateRouter = router({ mergeParams: true });
// TODO: remove it before releasing next major version
if (!Array.isArray(routes)) {
routes = [ routes ];
}
routes.forEach(route => {
const { paths, middlewares = [] } = route;

View File

@ -58,6 +58,43 @@ var analysisConfig = _.defaults(global.environment.analysis || {}, {
limits: {}
});
const routesConfig = global.environment.routes || {
api: [{
paths: [
'/api/v1',
'/user/:user/api/v1',
],
// Base url for the Detached Maps API
// "/api/v1/map" is the new API,
map: [{
paths: [
'/map',
]
}],
// Base url for the Templated Maps API
// "/api/v1/map/named" is the new API,
template: [{
paths: [
'/map/named'
]
}]
}]
};
if (!Array.isArray(routesConfig.api)) {
routesConfig.api = [ routesConfig.api ];
}
routesConfig.api.forEach(route => {
if (!Array.isArray(route.map)) {
route.map = [ route.map ];
}
if (!Array.isArray(route.template)) {
route.template = [ route.template ];
}
});
module.exports = {
bind: {
port: global.environment.port,
@ -66,28 +103,7 @@ module.exports = {
// Base URLs for the APIs
//
// See http://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API
routes: global.environment.routes || {
api: {
paths: [
'/api/v1',
'/user/:user/api/v1',
],
// Base url for the Detached Maps API
// "/api/v1/map" is the new API,
map: [{
paths: [
'/map',
]
}],
// Base url for the Templated Maps API
// "/api/v1/map/named" is the new API,
template: [{
paths: [
'/map/named'
]
}]
}
},
routes: routesConfig,
grainstore: {
map: {
// TODO: allow to specify in configuration