Update to have a configuration file out of the
app bundle.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { BrowserModule } from "@angular/platform-browser";
|
||||
import { NgModule } from "@angular/core";
|
||||
import { APP_INITIALIZER, NgModule } from "@angular/core";
|
||||
import { RouterModule, Routes } from "@angular/router";
|
||||
import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";
|
||||
|
||||
@@ -33,6 +33,7 @@ import { ServiceComm } from "../services/service-comm.service";
|
||||
import { RequestCache } from "../services/request-cache.service";
|
||||
import { AuthGuardService } from "../services/auth-guard.service";
|
||||
import { ImageService } from "../services/image.service";
|
||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||
|
||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
@@ -107,9 +108,14 @@ const appRoutes: Routes = [
|
||||
|
||||
{ path: "login", component: LoginComponent },
|
||||
|
||||
{ path: "**", redirectTo: "" },
|
||||
//{ path: "**", redirectTo: "" },
|
||||
];
|
||||
|
||||
// Déclaration de la fonction d'initialisation de la configuration
|
||||
export function initConfig(configService: ConfigurationHelper) {
|
||||
return () => configService.load(environment.env);
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
@@ -136,7 +142,6 @@ const appRoutes: Routes = [
|
||||
RouterModule.forRoot(
|
||||
appRoutes,
|
||||
{ enableTracing: !environment.production, relativeLinkResolution: 'legacy' } // <-- debugging purposes only
|
||||
// <-- debugging purposes only
|
||||
),
|
||||
ReactiveFormsModule,
|
||||
FormsModule,
|
||||
@@ -172,10 +177,13 @@ const appRoutes: Routes = [
|
||||
ServiceComm,
|
||||
DateService,
|
||||
RequestCache,
|
||||
// { provide: HTTP_INTERCEPTORS, useClass: CachingInterceptor, multi: true }
|
||||
ConfigurationHelper,
|
||||
{ provide: APP_INITIALIZER, useFactory: initConfig, deps: [ConfigurationHelper], multi: true },
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: JwtAuthInterceptor, multi: true },
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
|
||||
// { provide: HTTP_INTERCEPTORS, useClass: CachingInterceptor, multi: true }
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user