ngx-serial-route-guards
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

NgxSerialRouteGuards

Collection of utilities for executing functional route guards serially.

Examples

// guards
export const authGuard: CanActivateFn = () => {
  const router = inject(Router);
  const authService = inject(AuthService);
  return authService.isAuthenticated() || router.createUrlTree(['/auth/login']);
};

export const adminGuard: CanActivateFn = () => {
  const router = inject(Router);
  const userService = inject(UserService);
  return userService.user?.isAdmin || router.createUrlTree(['
  /unauthorized']);
};

...

// routes
const routes: Routes = [
  {
    path: '/admin',
    loadComponent: () => import('./admin/admin.page').then(m => m.AdminPage),
    canActivate: [runSerially([authGuard, adminGuard])]
  }
]

Package Sidebar

Install

npm i ngx-serial-route-guards

Weekly Downloads

60

Version

1.1.0

License

none

Unpacked Size

12.6 kB

Total Files

8

Last publish

Collaborators

  • tylerwigington