@experteam-mx/ngx-services 20.1.6 → 20.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,24 +1,80 @@
1
- # NgxServices
1
+ # @experteam-mx/ngx-services
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.0.
3
+ Common Angular services used across Experteam applications.
4
4
 
5
- ## Code scaffolding
5
+ ## Standalone setup (Angular v20+)
6
6
 
7
- Run `ng generate component component-name --project ngx-services` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-services`.
8
- > Note: Don't forget to add `--project ngx-services` or else it will be added to the default project in your `angular.json` file.
7
+ Use `provideNgxServices(environment)` in your `ApplicationConfig.providers`.
8
+
9
+ ```ts
10
+ import { provideHttpClient, withInterceptors } from '@angular/common/http'
11
+ import type { ApplicationConfig } from '@angular/core'
12
+ import { provideRouter } from '@angular/router'
13
+ import {
14
+ apiHeadersInterceptor,
15
+ apiTokenInterceptor,
16
+ httpCachingInterceptor,
17
+ provideNgxServices,
18
+ type Environment
19
+ } from '@experteam-mx/ngx-services'
20
+ import { environment } from '../environments/environment'
21
+ import { routes } from './app.routes'
22
+
23
+ const envs = {
24
+ ...environment,
25
+ authCookie: 'token',
26
+ cacheTtl: 3000
27
+ } as Environment
28
+
29
+ export const appConfig: ApplicationConfig = {
30
+ providers: [
31
+ provideRouter(routes),
32
+ provideNgxServices(envs),
33
+ provideHttpClient(withInterceptors([
34
+ apiHeadersInterceptor,
35
+ apiTokenInterceptor,
36
+ httpCachingInterceptor
37
+ ]))
38
+ ]
39
+ }
40
+ ```
41
+
42
+ `provideNgxServices` registers `ENVIRONMENT_TOKEN`, which is required by the API services and some interceptors in this package.
43
+
44
+ ## NgModule compatibility
45
+
46
+ `NgxServicesModule.forRoot(environment)` is still available for compatibility, but it is deprecated for new standalone applications and will be removed in `20.2.0`.
47
+
48
+ ```ts
49
+ import { importProvidersFrom } from '@angular/core'
50
+ import { NgxServicesModule } from '@experteam-mx/ngx-services'
51
+
52
+ providers: [
53
+ importProvidersFrom([NgxServicesModule.forRoot(envs)])
54
+ ]
55
+ ```
56
+
57
+ Prefer `provideNgxServices(envs)` for all new apps.
9
58
 
10
59
  ## Build
11
60
 
12
- Run `ng build ngx-services` to build the project. The build artifacts will be stored in the `dist/` directory.
61
+ ```bash
62
+ ng build @experteam-mx/ngx-services
63
+ ```
13
64
 
14
- ## Publishing
65
+ Build output:
15
66
 
16
- After building your library with `ng build ngx-services`, go to the dist folder `cd dist/ngx-services` and run `npm publish`.
67
+ `dist/experteam-mx/ngx-services`
17
68
 
18
- ## Running unit tests
69
+ ## Publish
19
70
 
20
- Run `ng test ngx-services` to execute the unit tests via [Karma](https://karma-runner.github.io).
71
+ ```bash
72
+ cd dist/experteam-mx/ngx-services
73
+ npm publish
74
+ ```
21
75
 
22
- ## Further help
76
+ ## Test
23
77
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
78
+ ```bash
79
+ ng test @experteam-mx/ngx-services
80
+ ```