This document details the Zastrozzi CDP Routing Library. This library provides the routing configuration and navigation framework for the Zastrozzi CDP suite. It integrates tightly with Angular Router to manage authenticated layouts, navigation panels, guards, and interceptors. It also aggregates route definitions for various features including home, customers, partner network, HMRC, and more.
The CDP Routing Library is designed to provide a flexible and maintainable routing framework for the CDP suite. It includes:
A high-level overview of the CDP Routing library layout (located in /packages/cdp/routing):
.eslintrc.json
jest.config.ts
ng-package.json
package.json
project.json
README.md
tsconfig.json
tsconfig.lib.json
tsconfig.lib.prod.json
tsconfig.spec.json
src/
index.ts
test-setup.ts
lib/
cdp-routing.module.ts // Main routing module that imports and configures the routes.
components/ // Reusable UI components for layout and navigation.
authed.container.component.ts
clipboard.utility-panel.component.ts
home.component.ts
notifications.utility-panel.component.ts
utility-dock.component.ts
index.ts // Re-exports components.
guards/ // Route guards to protect routes.
admin-user-auth.guard.ts
index.ts // Re-exports guards.
interceptors/ // Optional HTTP interceptors (e.g. logging).
// ... interceptor files.
routes/ // Folder containing route definitions.
cdp.routes.ts // Aggregated routes for CDP features.
enduser.routes.ts // Routes specific to enduser features.
// ... other route files.
cdp-routing.module.ts, it imports common modules (e.g. CommonModule, Angular Router modules), along with CDP and platform libraries (such as ZWPCommonModule, ZWPLayoutModule, ZWPAuthModule, etc.). It declares all internal routing components and provides additional providers such as logging interceptors when enabled.forRoot(enableLogging: boolean) method which conditionally registers providers (like an HTTP LoggingInterceptor) based on the passed flag.The routing library offers several reusable UI components that integrate with the navigation framework:
These components are re-exported via the internal components index for streamlined imports.
Routing guards secure the navigation flow. In this library, the primary guard is:
canActivate and canActivateChild.admin-user-auth.guard.ts and re-exported through the guards/index.ts file.Though not the primary focus of routing, HTTP interceptors can be configured to log or modify HTTP requests initiated during route navigation.
Interceptors are registered in the module via the HTTP_INTERCEPTORS provider token.
The routing library centralizes route definitions in the /src/lib/routes folder:
path: '') which displays the AuthedContainerComponent.AdminUserAuthGuard to secure access.Route data properties are used to configure navigation metadata such as navTitle, navIcon, and visibility toggles (e.g. leftNavPanelShown).
nx build cdp.routing
nx test cdp.routing
import { CDPRoutingModule } from '@zwp/cdp.routing';
@NgModule({
imports: [
// Other module imports
CDPRoutingModule.forRoot(true) // Pass true to enable HTTP logging interceptors if needed.
]
})
export class AppModule {}
The CDP Routing Library provides a robust framework for managing complex routing scenarios within the Zastrozzi CDP suite. By combining secure route guards, reusable navigation components, organized route definitions, and optional HTTP interceptors, this library ensures a consistent and maintainable navigation experience. Customize the routes and components as our project evolves to meet new requirements.
Feel free to update or expand this documentation as our project needs change.