Skip to content

Commit 20b6075

Browse files
committed
📝 Started working on README changes for date interceptors project
1 parent 26fa460 commit 20b6075

File tree

1 file changed

+73
-5
lines changed

1 file changed

+73
-5
lines changed

projects/date-interceptors/README.md

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
- [@ngx-toolset/date-interceptors](#ngx-toolsetdate-interceptors)
1111
- [Features](#features)
1212
- [Installation](#installation)
13+
- [NPM](#npm)
1314
- [Usage](#usage)
15+
- [Module Import](#module-import)
1416
- [Provide Injection Tokens](#provide-injection-tokens)
1517
- [Injection Tokens](#injection-tokens)
1618
- [API_DATE_FORMAT](#api_date_format)
@@ -26,16 +28,82 @@
2628
2729
## Installation
2830

29-
```
30-
ng add @ngx-toolset/date-interceptors
31-
```
31+
### NPM
32+
33+
`npm install @ngx-toolset/date-interceptors --save`
34+
35+
Choose the version corresponding to your Angular version:
36+
37+
| Angular | @ngx-toolset/date-interceptors |
38+
|---------|--------------------------------|
39+
| 14.x.x | >=0.0.1 <=1.0.0-rc.11 |
40+
| 15.x.x | 1.0.0-rc.12 |
41+
| 16.x.x | >=1.0.0-rc.13 <=2.0.0 |
3242

3343
## Usage
3444

45+
### Module Import
46+
47+
Import the `DateInterceptorsModule` in your `AppModule`:
48+
49+
```ts
50+
import { NgModule } from '@angular/core';
51+
import { BrowserModule } from '@angular/platform-browser';
52+
import { AppComponent } from './app.component';
53+
import { DateInterceptorsModule } from '@ngx-toolset/date-interceptors';
54+
55+
@NgModule({
56+
declarations: [AppComponent],
57+
imports: [
58+
BrowserModule,
59+
DateInterceptorsModule.forRoot(),
60+
],
61+
bootstrap: [AppComponent],
62+
})
63+
export class AppModule {}
64+
```
65+
3566
### Provide Injection Tokens
3667

37-
Provide proper values for automatically added `API_DATE_FORMAT`, `API_URL_REGEX` and `DATE_STRING_REGEX`
38-
injection tokens in your `AppModule`.
68+
Provide `API_DATE_FORMAT`, `API_URL_REGEX` and `DATE_STRING_REGEX` in your `AppModule`:
69+
70+
```ts
71+
import { NgModule } from '@angular/core';
72+
import { BrowserModule } from '@angular/platform-browser';
73+
import { AppComponent } from './app.component';
74+
import {
75+
DateInterceptorsModule,
76+
API_URL_REGEX,
77+
DATE_STRING_REGEX,
78+
API_DATE_FORMAT
79+
} from '@ngx-toolset/date-interceptors';
80+
81+
@NgModule({
82+
declarations: [AppComponent],
83+
imports: [
84+
BrowserModule,
85+
DateInterceptorsModule.forRoot(),
86+
],
87+
providers: [
88+
{
89+
provide: API_URL_REGEX,
90+
useValue: /^https:\/\/test-url.com/
91+
},
92+
{
93+
provide: DATE_STRING_REGEX,
94+
useValue: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,
95+
},
96+
{
97+
provide: API_DATE_FORMAT,
98+
useValue: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
99+
},
100+
],
101+
bootstrap: [AppComponent],
102+
})
103+
export class AppModule {}
104+
```
105+
106+
> Hint: The list of options to provide `API_DATE_FORMAT` value could be found here: [date-fns documentation](https://date-fns.org/v2.29.1/docs/parse).
39107
40108
## Injection Tokens
41109

0 commit comments

Comments
 (0)