Rename method 'register' -> 'route'

This commit is contained in:
Daniel García Aubert
2019-10-04 12:22:23 +02:00
parent dd06de2632
commit a684bead92
17 changed files with 35 additions and 37 deletions
+6 -8
View File
@@ -196,7 +196,7 @@ module.exports = class ApiRouter {
this.templateRouter = new TemplateRouter({ collaborators });
}
register (app, routes) {
route (app, routes) {
// FIXME: we need a better way to reset cache while running tests
if (process.env.NODE_ENV === 'test') {
app.layergroupAffectedTablesCache = this.layergroupAffectedTablesCache;
@@ -204,11 +204,9 @@ module.exports = class ApiRouter {
routes.forEach(route => {
const apiRouter = router({ mergeParams: true });
const { paths, middlewares = [] } = route;
const apiPaths = route.paths;
const apiMiddlewares = route.middlewares || [];
apiMiddlewares.forEach(middleware => apiRouter.use(middleware()));
middlewares.forEach(middleware => apiRouter.use(middleware()));
apiRouter.use(logger(this.serverOptions));
apiRouter.use(initializeStatusCode());
@@ -222,14 +220,14 @@ module.exports = class ApiRouter {
apiRouter.use(cors());
apiRouter.use(user());
this.templateRouter.register(apiRouter, route.template);
this.mapRouter.register(apiRouter, route.map);
this.templateRouter.route(apiRouter, route.template);
this.mapRouter.route(apiRouter, route.map);
apiRouter.use(sendResponse());
apiRouter.use(syntaxError());
apiRouter.use(errorMiddleware());
apiPaths.forEach(path => app.use(path, apiRouter));
paths.forEach(path => app.use(path, apiRouter));
});
}
};