-
Notifications
You must be signed in to change notification settings - Fork 85
/
core.module.ts
61 lines (59 loc) · 2.85 KB
/
core.module.ts
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 { APP_BASE_HREF, PlatformLocation } from '@angular/common';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule, Optional, SkipSelf } from '@angular/core';
import { ServiceWorkerModule } from '@angular/service-worker';
import { TranslateModule } from '@ngx-translate/core';
import { AppearanceModule } from './appearance.module';
import { ConfigurationModule } from './configuration.module';
import { FeatureToggleModule } from './feature-toggle.module';
import { IdentityProviderModule } from './identity-provider.module';
import { ICMErrorMapperInterceptor } from './interceptors/icm-error-mapper.interceptor';
import { IdentityProviderInterceptor } from './interceptors/identity-provider.interceptor';
import { MockInterceptor } from './interceptors/mock.interceptor';
import { PaymentPayoneInterceptor } from './interceptors/payment-payone.interceptor';
import { PGIDChangeInterceptor } from './interceptors/pgid-change.interceptor';
import { PreviewInterceptor } from './interceptors/preview.interceptor';
import { InternationalizationModule } from './internationalization.module';
import { StateManagementModule } from './state-management.module';
import { DefaultErrorHandler } from './utils/default-error-handler';
@NgModule({
imports: [
AppearanceModule,
ConfigurationModule,
FeatureToggleModule,
HttpClientModule,
IdentityProviderModule,
InternationalizationModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: SERVICE_WORKER }),
StateManagementModule,
],
providers: [
// include the ICMCompatibilityInterceptor to add support for REST API changes (e.g. messageToMerchant)
// { provide: HTTP_INTERCEPTORS, useClass: ICMCompatibilityInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: PGIDChangeInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ICMErrorMapperInterceptor, multi: true },
{
provide: HTTP_INTERCEPTORS,
useClass: IdentityProviderInterceptor,
multi: true,
},
{ provide: HTTP_INTERCEPTORS, useClass: PaymentPayoneInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: MockInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: PreviewInterceptor, multi: true },
{ provide: ErrorHandler, useClass: DefaultErrorHandler },
{
provide: APP_BASE_HREF,
useFactory: (s: PlatformLocation, baseHref: string) => baseHref || s.getBaseHrefFromDOM(),
deps: [PlatformLocation, [new Optional(), new SkipSelf(), APP_BASE_HREF]],
},
],
// exports needed to use the cookie banner in the AppComponent
exports: [TranslateModule],
})
export class CoreModule {
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
if (parentModule) {
throw new Error('CoreModule is already loaded. Import it in the AppModule only');
}
}
}