-
-
Save dev-sampsonorson/4b5dc0eb5bb571ce923cdee9b9a36521 to your computer and use it in GitHub Desktop.
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
@NgModule({ | |
imports: [OAuthModule.forRoot({...})] // <-- how to use the configuration.json here | |
}) | |
export class AppModule { | |
constructor(@Inject(AppConfig) private readonly appConfig: AppConfiguration) {} // I can inject | |
} |
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
{ | |
"apiBaseUrl": "https://localhost:5301" | |
} |
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
export interface AppConfiguration { | |
apiBaseUrl: string; | |
} | |
export const AppConfig = new InjectionToken<AppConfiguration>('@@appConfiguration'); |
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
(async () => { | |
try { | |
const config: AppConfiguration = await fetch('assets/configuration.json').then(res => res.json()); | |
if (config.production) { | |
console.log('Running in production mode'); | |
enableProdMode(); | |
} | |
platformBrowserDynamic([ | |
{ provide: AppConfig, useValue: config } | |
]).bootstrapModule(AppModule) | |
.catch(err => console.error(err)); | |
} catch (e) { | |
console.error('Error initializing', e); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment