} from 'ui-common'
import { type App as AppType, type Component, createApp, ref } from 'vue'
-import ToastPlugin from 'vue-toast-notification'
import App from '@/App.vue'
import {
}
}
-const app = createApp(App as Component)
-
const initializeApp = async (app: AppType, config: ConfigurationData): Promise<void> => {
await loadTheme(config.theme ?? DEFAULT_THEME)
app.config.errorHandler = (error, instance, info) => {
app.provide(chargingStationsKey, chargingStations)
app.provide(templatesKey, templates)
app.provide(uiClientKey, uiClient)
- app.use(router).use(ToastPlugin).mount('#app')
+ app.use(router).mount('#app')
}
-try {
- const response = await fetch('/config.json')
+const bootstrap = async (): Promise<void> => {
+ const app = createApp(App as Component)
+ let response: Response
+ try {
+ response = await fetch('/config.json')
+ } catch (error: unknown) {
+ console.error('Error at fetching app configuration:', error)
+ return
+ }
if (!response.ok) {
- // TODO: add code for UI notifications or other error handling logic
console.error('Failed to fetch app configuration')
- } else {
- try {
- const config = (await response.json()) as ConfigurationData
- await initializeApp(app, config)
- } catch (error: unknown) {
- // TODO: add code for UI notifications or other error handling logic
- console.error('Error at deserializing JSON app configuration:', error)
- }
+ return
+ }
+ let config: ConfigurationData
+ try {
+ config = (await response.json()) as ConfigurationData
+ } catch (error: unknown) {
+ console.error('Error at deserializing JSON app configuration:', error)
+ return
+ }
+ try {
+ await initializeApp(app, config)
+ } catch (error: unknown) {
+ console.error('Error at initializing app:', error)
}
-} catch (error: unknown) {
- // TODO: add code for UI notifications or other error handling logic
- console.error('Error at fetching app configuration:', error)
}
+
+bootstrap().catch(console.error)