-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Answer: 31 #1153
Closed
michalgrzegorczyk-dev
wants to merge
1
commit into
tomalaforge:main
from
hsidfufdishufdihusdfhudf:31-module-to-standalone
Closed
Answer: 31 #1153
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
apps/angular/31-module-to-standalone/src/app/app.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { AppModule } from './app/app.module'; | ||
import { provideToken } from '@angular-challenges/module-to-standalone/core/providers'; | ||
import { appRoutes } from '@angular-challenges/module-to-standalone/shell'; | ||
import { bootstrapApplication } from '@angular/platform-browser'; | ||
import { provideRouter } from '@angular/router'; | ||
import { AppComponent } from './app/app.component'; | ||
|
||
platformBrowserDynamic() | ||
.bootstrapModule(AppModule) | ||
.catch((err) => console.error(err)); | ||
bootstrapApplication(AppComponent, { | ||
providers: [provideRouter(appRoutes), provideToken('main-shell-token')], | ||
}).catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/admin-feature.module'; | ||
export { ADMIN_ROUTES } from './lib/admin-feature.routes'; |
27 changes: 0 additions & 27 deletions
27
libs/module-to-standalone/admin/feature/src/lib/admin-feature.module.ts
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
libs/module-to-standalone/admin/feature/src/lib/admin-feature.routes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Routes } from '@angular/router'; | ||
|
||
export const ADMIN_ROUTES: Routes = [ | ||
{ | ||
path: '', | ||
loadComponent: () => | ||
import('./dashboard/dashboard.component').then( | ||
(m) => m.DashboardComponent, | ||
), | ||
}, | ||
{ | ||
path: 'create-user', | ||
loadComponent: () => | ||
import('./create-user/create-user.component').then( | ||
(m) => m.CreateUserComponent, | ||
), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 11 additions & 19 deletions
30
libs/module-to-standalone/admin/shared/src/lib/authorized.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
import { CanActivate, Router, UrlTree } from '@angular/router'; | ||
|
||
import { AuthorizationService } from '@angular-challenges/module-to-standalone/core/service'; | ||
import { Injectable } from '@angular/core'; | ||
import { inject } from '@angular/core'; | ||
import { Router, UrlTree } from '@angular/router'; | ||
import { Observable, map } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class IsAuthorizedGuard implements CanActivate { | ||
constructor( | ||
private authorizationService: AuthorizationService, | ||
private router: Router, | ||
) {} | ||
export const isAuthorizedGuard = (): Observable<boolean | UrlTree> => { | ||
const authorizationService = inject(AuthorizationService); | ||
const router = inject(Router); | ||
|
||
canActivate(): Observable<boolean | UrlTree> { | ||
return this.authorizationService.isAuthorized$.pipe( | ||
map((isAuthorized) => | ||
isAuthorized ? true : this.router.createUrlTree(['forbidden']), | ||
), | ||
); | ||
} | ||
} | ||
return authorizationService.isAuthorized$.pipe( | ||
map((isAuthorized) => | ||
isAuthorized ? true : router.createUrlTree(['forbidden']), | ||
), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/forbidden.module'; | ||
export { ForbiddenComponent } from './lib/forbidden.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
libs/module-to-standalone/forbidden/src/lib/forbidden.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/home.module'; | ||
export { HomeComponent } from './lib/home.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/main-shell.module'; | ||
export * from './lib/main-shell.routes'; |
11 changes: 0 additions & 11 deletions
11
libs/module-to-standalone/shell/src/lib/main-shell.module.ts
This file was deleted.
Oops, something went wrong.
17 changes: 8 additions & 9 deletions
17
libs/module-to-standalone/shell/src/lib/main-shell.routes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
import { IsAuthorizedGuard } from '@angular-challenges/module-to-standalone/admin/shared'; | ||
import { Route } from '@angular/router'; | ||
import { isAuthorizedGuard } from 'libs/module-to-standalone/admin/shared/src/lib/authorized.guard'; | ||
|
||
export const appRoutes: Route[] = [ | ||
{ path: '', redirectTo: 'home', pathMatch: 'full' }, | ||
{ | ||
path: 'home', | ||
loadChildren: () => | ||
loadComponent: () => | ||
import('@angular-challenges/module-to-standalone/home').then( | ||
(m) => m.ModuleToStandaloneHomeModule, | ||
(m) => m.HomeComponent, | ||
), | ||
}, | ||
{ | ||
path: 'admin', | ||
canActivate: [IsAuthorizedGuard], | ||
canActivate: [isAuthorizedGuard], | ||
loadChildren: () => | ||
import('@angular-challenges/module-to-standalone/admin/feature').then( | ||
(m) => m.AdminFeatureModule, | ||
(r) => r.ADMIN_ROUTES, | ||
), | ||
}, | ||
{ | ||
path: 'user', | ||
loadChildren: () => | ||
import('@angular-challenges/module-to-standalone/user/shell').then( | ||
(m) => m.UserShellModule, | ||
(m) => m.USER_ROUTES, | ||
), | ||
}, | ||
|
||
{ | ||
path: 'forbidden', | ||
loadChildren: () => | ||
loadComponent: () => | ||
import('@angular-challenges/module-to-standalone/forbidden').then( | ||
(m) => m.ForbiddenModule, | ||
(m) => m.ForbiddenComponent, | ||
), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/contact-feature.module'; | ||
export * from './lib/contact-feature.routes'; |
27 changes: 0 additions & 27 deletions
27
libs/module-to-standalone/user/contact/src/lib/contact-feature.module.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
libs/module-to-standalone/user/contact/src/lib/contact-feature.routes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Route } from '@angular/router'; | ||
import { CreateContactComponent } from './create-contact/create-contact.component'; | ||
import { ContactDashboardComponent } from './dashboard/dashboard.component'; | ||
|
||
export const contactFeatureRoutes: Route[] = [ | ||
{ | ||
path: '', | ||
component: ContactDashboardComponent, | ||
children: [ | ||
{ | ||
path: 'create-contact', | ||
component: CreateContactComponent, | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the default keyword is you want to avoid the then close. But that's only a proposal, some people prefer it more explicit