Use Object.values()

This commit is contained in:
Daniel García Aubert
2019-10-02 10:42:29 +02:00
parent 5fe6845d7c
commit 975f07df99
+6 -7
View File
@@ -202,10 +202,11 @@ module.exports = class ApiRouter {
app.layergroupAffectedTablesCache = this.layergroupAffectedTablesCache;
}
Object.keys(this.serverOptions.routes).forEach(api => {
const routes = this.serverOptions.routes[api];
Object.values(this.serverOptions.routes).forEach(route => {
const apiRouter = router({ mergeParams: true });
const apiMiddlewares = routes.middlewares || [];
const apiPaths = route.paths;
const apiMiddlewares = route.middlewares || [];
apiMiddlewares.forEach(middleware => apiRouter.use(middleware()));
@@ -221,15 +222,13 @@ module.exports = class ApiRouter {
apiRouter.use(cors());
apiRouter.use(user());
this.templateRouter.register(apiRouter, routes.template.paths, routes.template.middlewares);
this.mapRouter.register(apiRouter, routes.map.paths, routes.map.middlewares);
this.templateRouter.register(apiRouter, route.template.paths, route.template.middlewares);
this.mapRouter.register(apiRouter, route.map.paths, route.map.middlewares);
apiRouter.use(sendResponse());
apiRouter.use(syntaxError());
apiRouter.use(errorMiddleware());
const apiPaths = routes.paths;
apiPaths.forEach(path => app.use(path, apiRouter));
});
}