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