Use a better API to define public routes
This commit is contained in:
parent
c0943a7c58
commit
e06d3200c3
@ -206,7 +206,7 @@ module.exports = class ApiRouter {
|
||||
apiRouter.use(syntaxError());
|
||||
apiRouter.use(errorMiddleware());
|
||||
|
||||
const paths = this.serverOptions.api_base_paths;
|
||||
const paths = this.serverOptions.routes.api.paths;
|
||||
|
||||
app.use(`(?:${paths.join('|')})`, apiRouter);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ module.exports = class MapRouter {
|
||||
this.previewTemplateController.register(mapRouter);
|
||||
this.analysesController.register(mapRouter);
|
||||
|
||||
const paths = this.serverOptions.map_base_paths;
|
||||
const paths = this.serverOptions.routes.api.map.paths;
|
||||
|
||||
apiRouter.use(`(?:${paths.join('|')})`, mapRouter);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ module.exports = class TemplateRouter {
|
||||
this.tileTemplateController.register(templateRouter);
|
||||
this.adminTemplateController.register(templateRouter);
|
||||
|
||||
const paths = this.serverOptions.template_base_paths;
|
||||
const paths = this.serverOptions.routes.api.template.paths;
|
||||
|
||||
apiRouter.use(`(?:${paths.join('|')})`, templateRouter);
|
||||
}
|
||||
|
@ -67,18 +67,24 @@ module.exports = {
|
||||
// FIXME: Remove it. This is no longer needed, paths are defined in routers
|
||||
base_url_templated: global.environment.base_url_templated || '(?:/maps/named|/tiles/template)',
|
||||
|
||||
api_base_paths: global.environment.api_base_paths || [
|
||||
routes: global.environment.routes || {
|
||||
api: {
|
||||
paths: [
|
||||
'/api/v1',
|
||||
'/user/:user/api/v1'
|
||||
],
|
||||
|
||||
map_base_paths: global.environment.map_base_paths || [
|
||||
map: {
|
||||
paths: [
|
||||
'/map'
|
||||
],
|
||||
|
||||
template_base_paths: global.environment.template_base_paths || [
|
||||
]
|
||||
},
|
||||
template: {
|
||||
paths: [
|
||||
'/map/named'
|
||||
],
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
grainstore: {
|
||||
map: {
|
||||
|
@ -12,18 +12,24 @@ module.exports = _.extend({}, serverOptions, {
|
||||
// FIXME: Remove it. This is no longer needed, paths are defined in routers
|
||||
base_url_mapconfig: '/database/:dbname/layergroup',
|
||||
|
||||
api_base_paths: [
|
||||
routes: {
|
||||
api: {
|
||||
paths: [
|
||||
'/tiles',
|
||||
'/database/:dbname'
|
||||
],
|
||||
|
||||
map_base_paths: [
|
||||
map: {
|
||||
paths: [
|
||||
'/layergroup'
|
||||
],
|
||||
|
||||
template_base_paths: [
|
||||
]
|
||||
},
|
||||
template: {
|
||||
paths: [
|
||||
'/template'
|
||||
],
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
grainstore: {
|
||||
datasource: {
|
||||
|
Loading…
Reference in New Issue
Block a user