Add database connection check

This commit is contained in:
Ben Goldsworthy 2020-11-28 19:36:19 +00:00
parent 94ee509b43
commit bfb9f9b582
2 changed files with 19 additions and 1 deletions

View file

@ -93,7 +93,18 @@ import { FilterPipeModule } from 'ngx-filter-pipe';
bootstrap: [ AppComponent ]
})
export class AppModule {
constructor () {
constructor (
private api: ApiService,
) {
this.api.checkDatabaseConnection().subscribe(
result => {
},
error => {
document.location = '#/500';
throw new Error('Server connection fail');
}
);
if (environment.enableAnalytics) {
(<any>window).ga('create', environment.analyticsKey, 'auto');
}

View file

@ -42,6 +42,13 @@ export class ApiService {
localStorage.removeItem('sessionKey');
}
public checkDatabaseConnection() {
return this.http.post<any>(
this.apiUrl,
null
);
}
public register(data) {
return this.http.post<any>(
this.apiUrl + '/register',