Skip to content

Instantly share code, notes, and snippets.

@GlauberF
Last active July 19, 2019 20:41
Show Gist options
  • Save GlauberF/15f65be95fae5ecff2184c1f861be041 to your computer and use it in GitHub Desktop.
Save GlauberF/15f65be95fae5ecff2184c1f861be041 to your computer and use it in GitHub Desktop.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler, Injectable, LOCALE_ID } from '@angular/core';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule, Routes } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import 'hammerjs';
import ptBr from '@angular/common/locales/pt';
import { registerLocaleData } from '@angular/common';
import { VimboModule } from '@vimbo/vimbo.module';
import {
VimboProgressBarModule,
VimboSidebarModule,
VimboThemeOptionsModule
} from '@vimbo/components';
import { vimboConfig } from 'app/vimbo-config';
import { AppComponent } from 'app/app.component';
import { AppStoreModule } from 'app/store/store.module';
import { LayoutModule } from 'app/layout/layout.module';
import { TokenInterceptorService } from '@vimbo/services/token-interceptor.service';
import { HttpLinkModule } from 'apollo-angular-link-http';
import { ApolloModule } from 'apollo-angular';
import { GraphQLModule } from './graphql.module';
import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';
import { init, captureException } from '@sentry/browser';
init({
dsn: 'https://3333333333333333333333@sentry.io/1429610'
});
// language
if (
!window.localStorage.getItem('language') ||
(window.localStorage.getItem('language') &&
window.localStorage.getItem('language') !== 'en')
) {
registerLocaleData(ptBr);
}
const appRoutes: Routes = [
{
path: 'apps',
loadChildren: () =>
import('./main/apps/apps.module').then(m => m.AppsModule)
},
{
path: 'pages',
loadChildren: () =>
import('./main/pages/pages.module').then(m => m.PagesModule)
},
{
path: '**',
redirectTo: 'apps/dashboards'
}
];
@Injectable()
export class SentryErrorHandler implements ErrorHandler {
constructor() {}
handleError(error): any {
if (error) {
captureException(error.originalError || error);
throw error;
}
}
}
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
GraphQLModule,
BrowserAnimationsModule,
HttpClientModule,
RouterModule.forRoot(appRoutes),
TranslateModule.forRoot(),
// vimbo modules
VimboModule.forRoot(vimboConfig),
VimboProgressBarModule,
VimboSidebarModule,
VimboThemeOptionsModule,
// App modules
LayoutModule,
AppStoreModule,
// graphql apollo
ApolloModule,
HttpLinkModule,
// worker
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: environment.production
})
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptorService,
multi: true
},
{
provide: LOCALE_ID,
useValue:
window.localStorage.getItem('language') &&
window.localStorage.getItem('language') === 'en'
? 'en-US'
: 'pt'
},
{
provide: ErrorHandler,
useClass: SentryErrorHandler
}
],
bootstrap: [AppComponent]
})
export class AppModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment