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,16 +58,8 @@ var analysisConfig = _.defaults(global.environment.analysis || {}, {
limits: {}
});
module.exports = {
bind: {
port: global.environment.port,
host: global.environment.host
},
// Base URLs for the APIs
//
// See http://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API
routes: global.environment.routes || {
api: {
const routesConfig = global.environment.routes || {
api: [{
paths: [
'/api/v1',
'/user/:user/api/v1',
@ -86,8 +78,32 @@ module.exports = {
'/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,
host: global.environment.host
},
// Base URLs for the APIs
//
// See http://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API
routes: routesConfig,
grainstore: {
map: {
// TODO: allow to specify in configuration