@experteam-mx/ngx-services
v20.2.2
Published
Angular common services for Experteam apps
Maintainers
Readme
@experteam-mx/ngx-services
Common Angular services used across Experteam applications.
Standalone setup (Angular v20+)
Use provideNgxServices(environment) in your ApplicationConfig.providers.
import { provideHttpClient, withInterceptors } from '@angular/common/http'
import type { ApplicationConfig } from '@angular/core'
import { provideRouter } from '@angular/router'
import {
apiHeadersInterceptor,
apiTokenInterceptor,
httpCachingInterceptor,
provideNgxServices,
type Environment
} from '@experteam-mx/ngx-services'
import { environment } from '../environments/environment'
import { routes } from './app.routes'
const envs = {
...environment,
authCookie: 'token',
cacheTtl: 3000
} as Environment
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideNgxServices(envs),
provideHttpClient(withInterceptors([
apiHeadersInterceptor,
apiTokenInterceptor,
httpCachingInterceptor
]))
]
}provideNgxServices registers ENVIRONMENT_TOKEN, which is required by the API services and some interceptors in this package.
NgModule compatibility
NgxServicesModule.forRoot(environment) is still available for compatibility, but it is deprecated for new standalone applications and will be removed in 20.2.0.
import { importProvidersFrom } from '@angular/core'
import { NgxServicesModule } from '@experteam-mx/ngx-services'
providers: [
importProvidersFrom([NgxServicesModule.forRoot(envs)])
]Prefer provideNgxServices(envs) for all new apps.
Build
ng build @experteam-mx/ngx-servicesBuild output:
dist/experteam-mx/ngx-services
Publish
cd dist/experteam-mx/ngx-services
npm publishTest
ng test @experteam-mx/ngx-services