-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathapp.config.ts
More file actions
61 lines (55 loc) · 2.21 KB
/
Copy pathapp.config.ts
File metadata and controls
61 lines (55 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { ApplicationConfig, LOCALE_ID, importProvidersFrom, inject } from '@angular/core';
import { Title } from '@angular/platform-browser';
import {
NavigationError,
Router,
RouterFeatures,
TitleStrategy,
provideRouter,
withComponentInputBinding,
withDebugTracing,
withNavigationErrorHandler,
} from '@angular/router';
import { provideServiceWorker } from '@angular/service-worker';
import { NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap/datepicker';
import { environment } from 'environments/environment';
import { authExpiredInterceptor } from 'app/core/interceptor/auth-expired.interceptor';
import { errorHandlerInterceptor } from 'app/core/interceptor/error-handler.interceptor';
import { notificationInterceptor } from 'app/core/interceptor/notification.interceptor';
import './config/dayjs';
import { TranslationModule } from 'app/shared/language/translation.module';
import { AppPageTitleStrategy } from './app-page-title-strategy';
import routes from './app.routes';
import { NgbDateDayjsAdapter } from './config/datepicker-adapter';
const routerFeatures: RouterFeatures[] = [
withComponentInputBinding(),
withNavigationErrorHandler((e: NavigationError) => {
const router = inject(Router);
if (e.error.status === 403) {
router.navigate(['/accessdenied']);
} else if (e.error.status === 404) {
router.navigate(['/404']);
} else if (e.error.status === 401) {
router.navigate(['/login']);
} else {
router.navigate(['/error']);
}
}),
];
if (environment.DEBUG_INFO_ENABLED) {
routerFeatures.push(withDebugTracing());
}
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes, ...routerFeatures),
// Set this to true to enable service worker (PWA)
provideServiceWorker('ngsw-worker.js', { enabled: false }),
importProvidersFrom(TranslationModule),
provideHttpClient(withInterceptors([authExpiredInterceptor, errorHandlerInterceptor, notificationInterceptor])),
Title,
{ provide: LOCALE_ID, useValue: 'en' },
{ provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter },
{ provide: TitleStrategy, useClass: AppPageTitleStrategy },
],
};