@mbd-common-libs/angular-common-services
v2.60.2
Published
Store models and services for creating a marketplace instance.
Downloads
1
Readme
angular-common-services
Services Built With
About the library
Store models and services for creating a marketplace instance:
- API services.
- user authorization.
- marketplace endpoints.
- Models :
- request and response models.
- Utils:
- CSRF interceptor. Syncs CSRF token between pages.
Services Dependencies
"jwt-decode": "3.1.2",
"broadcast-channel": "3.5.3",
"isbot": "^3.3.1"
Services Installation
- Install dependencies
npm i --save [email protected] [email protected]
- Install library
npm i @mbd-common-libs/angular-common-services
Import OcCommonServiceModule
Note: OcCommonServiceModule provide API services.
Add import to app.module
@NgModule({
imports: [
...
OcCommonServiceModule.forRoot({apiUrl: 'main api path for all API services'}),
]
})
export class AppModule {}
Example:
OcCommonServiceModule.forRoot({apiUrl: 'https://client-api.openchannel.io/'})
Import CustomHttpClientXsrfModule
Note: CustomHttpClientXsrfModule provide CSRF intercepors. Interceptors take CSRF response header, then put it into memory storage and insert this header for all requests by this API URL.
Add import to app.module
@NgModule({
imports: [
...
CustomHttpClientXsrfModule.withOptions({ headerName: 'X-CSRF-TOKEN', apiUrl: 'main api path for all API calls' }),
]
})
export class AppModule {}
Example:
CustomHttpClientXsrfModule.withOptions({ headerName: 'X-CSRF-TOKEN', apiUrl: 'https://client-api.openchannel.io/' })
Import NetlifyPrerenderModule
Note: NetlifyPrerenderModule provide HttpRequestsWatcherInterceptor for the Netlify pre-render.
Add import to app.module
@NgModule({
imports: [
...
NetlifyPrerenderModule.withOptions({ endpointsConfigForPrerender: 'your pre-render config can be passed here' }),
]
})
export class AppModule {}
Example:
NetlifyPrerenderModule.withOptions({ endpointsConfigForPrerender: yourPrerenderEndpointsConfig }),
Connect library to project by link
Note: Run commands from the root directory.
npm i
ng build angular-common-services --watch
cd ./dist/angular-common-services
sudo npm link
Then copy result link.- Example:
- Command Result (sudo npm link):
/usr/local/lib/node_modules/@mbd-common-libs/angular-common-services -> /home/user/git/angular-template-libraries/dist/angular-common-services
- Copy link:
/home/user/git/angular-template-libraries/dist/angular-common-services
- Command Result (sudo npm link):
- Example:
In your angular project run:
npm install file:{absolute path to angular-common-services or copied path}/dist/angular-common-services
- Example:
npm install file:/home/user/git/angular-template-libraries/dist/angular-common-services
- Example:
Use imports into ts files :
import { CustomHttpClientXsrfModule } from '@mbd-common-libs/angular-common-services';