import { HttpClient, HttpClientModule } from '@angular/common/http'; import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { JwtModule } from '@auth0/angular-jwt'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { ConfirmationService, MessageService } from 'primeng/api'; import { DialogService } from 'primeng/dynamicdialog'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { NotFoundComponent } from './components/error/not-found/not-found.component'; import { FooterComponent } from './components/footer/footer.component'; import { HeaderComponent } from './components/header/header.component'; import { SidebarComponent } from './components/sidebar/sidebar.component'; import { SpinnerComponent } from './components/spinner/spinner.component'; import { SharedModule } from './modules/shared/shared.module'; import { ErrorHandlerService } from './services/error-handler/error-handler.service'; import { SettingsService } from './services/settings/settings.service'; @NgModule({ declarations: [ AppComponent, HeaderComponent, SidebarComponent, FooterComponent, SpinnerComponent, NotFoundComponent, ], imports: [ BrowserModule, BrowserAnimationsModule, AppRoutingModule, SharedModule, JwtModule.forRoot({ config: { tokenGetter, allowedDomains: ['localhost:8044', 'localhost:8041', 'localhost:5000'], disallowedRoutes: [] } }), TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpClient] } }), HttpClientModule ], providers: [ { provide: APP_INITIALIZER, useFactory: configurationFactory, deps: [SettingsService], multi: true }, { provide: ErrorHandler, useClass: ErrorHandlerService }, MessageService, ConfirmationService, DialogService ], bootstrap: [AppComponent] }) export class AppModule { } export function configurationFactory(settingsService: SettingsService): () => Promise { return (): Promise => { return settingsService.loadSettings(); }; } export function tokenGetter(): string { return localStorage.getItem('jwt') ?? ''; } export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { return new TranslateHttpLoader(http); }