diff --git a/src/loaders/admin-api.loader.ts b/src/loaders/admin-api.loader.ts index 8f4c2962..31ce6292 100644 --- a/src/loaders/admin-api.loader.ts +++ b/src/loaders/admin-api.loader.ts @@ -18,26 +18,18 @@ export async function adminApiLoader( const adminMiddlewares = middlewares .map((middleware) => ({ ...middleware, - routes: middleware.routes.filter((route) => { - if (route.path.startsWith('/admin')) { - route.path = route.path.replace('/admin', ''); - return true; - } - return false; - }), + routes: middleware.routes + .filter((route) => route.path.startsWith('/admin')) + .map((route) => ({ ...route, path: route.path.replace('/admin', '') })), })) .filter((middleware) => middleware.routes.length); const adminRouters = routers .map((router) => ({ ...router, - routes: router.routes.filter((route) => { - if (route.path.startsWith('/admin')) { - route.path = route.path.replace('/admin', ''); - return true; - } - return false; - }), + routes: router.routes + .filter((route) => route.path.startsWith('/admin')) + .map((route) => ({ ...route, path: route.path.replace('/admin', '') })), })) .filter((route) => route.routes.length); diff --git a/src/loaders/store-api.loader.ts b/src/loaders/store-api.loader.ts index 9959197c..2c01740a 100644 --- a/src/loaders/store-api.loader.ts +++ b/src/loaders/store-api.loader.ts @@ -18,26 +18,18 @@ export async function storeApiLoader( const storeMiddlewares = middlewares .map((middleware) => ({ ...middleware, - routes: middleware.routes.filter((route) => { - if (route.path.startsWith('/store')) { - route.path = route.path.replace('/store', ''); - return true; - } - return false; - }), + routes: middleware.routes + .filter((route) => route.path.startsWith('/store')) + .map((route) => ({ ...route, path: route.path.replace('/store', '') })), })) .filter((middleware) => middleware.routes.length); const storeRouters = routers .map((router) => ({ ...router, - routes: router.routes.filter((route) => { - if (route.path.startsWith('/store')) { - route.path = route.path.replace('/store', ''); - return true; - } - return false; - }), + routes: router.routes + .filter((route) => route.path.startsWith('/store')) + .map((route) => ({ ...route, path: route.path.replace('/store', '') })), })) .filter((route) => route.routes.length);