Add database connection check
This commit is contained in:
parent
94ee509b43
commit
bfb9f9b582
2 changed files with 19 additions and 1 deletions
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
Reference in a new issue