@cauca-911/core
v21.3.2
Published
Run `npm install @cauca-911/core` to add this library to your project.
Readme
@cauca-911/core
Run npm install @cauca-911/core to add this library to your project.
Setup
Use provideCaucaCore() in your application configuration:
export const appConfig: ApplicationConfig = {
providers: [
provideCaucaCore({
logLevel: LogLevel.warning, // default: LogLevel.error
logError: (logLevel, message, data) => void, // default: no-op
apiUrl: 'http://example.com/api/', // default: ''
languages: ['fr'], // default: ['fr', 'en']
loginURL: () => '/login', // default: () => '/login/'
allowRefreshToken: true, // default: false
refreshLoginURL: '/refreshLogin', // default: ''
libraries: ['devextreme', 'material'], // default: []
i18nPaths: ['additional-folder'], // default: []
locale: 'fr', // default: ''
jsonConfigFile: 'path/config.json', // default: ''
nbRetryOnNetworkError: 2, // default: 0
contentSecurityPolicyActivated: true, // default: false
}),
provideHttpClient(withInterceptorsFromDi()),
]
};See CoreModuleOptions for all available options.
Unit Testing
Use provideTestingTranslation() to replace TranslateService with a lightweight synchronous mock:
TestBed.configureTestingModule({
providers: [
...provideTestingTranslation(),
]
});Pass an optional key→value map to control resolved translations:
...provideTestingTranslation({ 'my.key': 'My Value' })Components
CaucaPageNotFoundComponent— Add the**route to your routing:{ path: '**', component: CaucaPageNotFoundComponent }
Services
CaucaCoreService—getConfig()returns the active configuration.ClientInformationServiceFullscreenServiceImageServiceLogServicepublishError— Posts errors to the web API at{apiUrl}Error/logErrorsor{apiUrl}logErrors.information,warning,error,disconnection— Log at the correspondingLogLevel.
NetworkInformationServiceVersionCheckService
HTTP Interceptors
HttpOfflineInterceptor— Returns an error when the client is offline.HttpTokenWriterInterceptor— AddsAuthorizationandCSRFheaders when configured.HttpTokenReaderInterceptor— Reads the CSRF token from responses.HttpErrorInterceptor— Catches HTTP errors and displays them via Angular Material's snack bar.
Generic Classes
ConfigurationBrowserColorOperatingSystem
