@adaskothebeast/angular-date-http-interceptor 1.2.0 → 3.0.0
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/LICENSE +21 -0
- package/README.md +10 -24
- package/esm2022/adaskothebeast-angular-date-http-interceptor.mjs +1 -1
- package/esm2022/index.mjs +1 -1
- package/esm2022/lib/angular-date-http-interceptor.module.mjs +5 -5
- package/esm2022/lib/hierarchical-date-adjust-symbol.mjs +1 -1
- package/esm2022/lib/hierarchical-date-http-interceptor.mjs +6 -6
- package/fesm2022/adaskothebeast-angular-date-http-interceptor.mjs +9 -9
- package/fesm2022/adaskothebeast-angular-date-http-interceptor.mjs.map +1 -1
- package/package.json +17 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Adam Pluciński
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -337,33 +337,18 @@ This will initiate the fetch when your component mounts and dispatch either a su
|
|
|
337
337
|
|
|
338
338
|
Please adjust the code according to your requirements and project structure.
|
|
339
339
|
|
|
340
|
-
### Axios
|
|
340
|
+
### Axios with AxiosInstanceManager
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
The AxiosInstanceManager class simplifies the process of using Axios with the `hierarchicalConvertToDate` function. By utilizing this class, you can easily create and use a centralized Axios instance with a response interceptor that automatically processes response data.
|
|
343
343
|
|
|
344
|
-
Here
|
|
344
|
+
Here's how to use AxiosInstanceManager:
|
|
345
345
|
|
|
346
346
|
```ts
|
|
347
|
-
import
|
|
348
|
-
|
|
349
|
-
// Adjust this import as needed - this will import adjustment function for pure js Date object
|
|
347
|
+
import { AxiosInstanceManager } from '@adaskothebeast/axios-interceptor';
|
|
350
348
|
import { hierarchicalConvertToDate } from '@adaskothebeast/hierarchical-convert-to-date';
|
|
351
349
|
|
|
352
|
-
// Create an instance
|
|
353
|
-
const instance =
|
|
354
|
-
|
|
355
|
-
// Add a response interceptor
|
|
356
|
-
instance.interceptors.response.use((response) => {
|
|
357
|
-
// Any status code that lies within the range of 2xx cause this function to trigger
|
|
358
|
-
// Parse the dates in the response data
|
|
359
|
-
hierarchicalConvertToDate(response.data);
|
|
360
|
-
// Then return the response object
|
|
361
|
-
return response;
|
|
362
|
-
}, (error) => {
|
|
363
|
-
// Any status codes that falls outside the range of 2xx cause this function to trigger
|
|
364
|
-
// You can handle the error here
|
|
365
|
-
return Promise.reject(error);
|
|
366
|
-
});
|
|
350
|
+
// Create an Axios instance using AxiosInstanceManager
|
|
351
|
+
const instance = AxiosInstanceManager.createInstance(hierarchicalConvertToDate);
|
|
367
352
|
|
|
368
353
|
async function fetchApiData() {
|
|
369
354
|
try {
|
|
@@ -377,8 +362,9 @@ async function fetchApiData() {
|
|
|
377
362
|
fetchApiData();
|
|
378
363
|
```
|
|
379
364
|
|
|
380
|
-
In the code above
|
|
365
|
+
In the code above:
|
|
381
366
|
|
|
382
|
-
The
|
|
367
|
+
- The createInstance method of AxiosInstanceManager is used to create and configure an Axios instance. This instance is configured with a response interceptor that applies hierarchicalConvertToDate to response.data. This conversion function processes any date strings in the response data into JavaScript Date objects (or in case of other libs proper class for given date lib).
|
|
368
|
+
- The fetchApiData function demonstrates using the configured Axios instance to make a GET request. The response data, with date strings already converted into Date (or in case of other libs proper class for given date lib) objects, is logged to the console. Errors from the request are caught and logged.
|
|
383
369
|
|
|
384
|
-
|
|
370
|
+
This approach encapsulates the Axios configuration, making your code cleaner and more maintainable. Remember to adjust imports and function calls as per your project's file structure and requirements.
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
4
|
export * from './index';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRhc2tvdGhlYmVhc3QtYW5ndWxhci1kYXRlLWh0dHAtaW50ZXJjZXB0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItZGF0ZS1odHRwLWludGVyY2VwdG9yL3NyYy9hZGFza290aGViZWFzdC1hbmd1bGFyLWRhdGUtaHR0cC1pbnRlcmNlcHRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|
package/esm2022/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './lib/angular-date-http-interceptor.module';
|
|
2
2
|
export * from './lib/hierarchical-date-adjust-symbol';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItZGF0ZS1odHRwLWludGVyY2VwdG9yL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDRDQUE0QyxDQUFDO0FBQzNELGNBQWMsdUNBQXVDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2xpYi9hbmd1bGFyLWRhdGUtaHR0cC1pbnRlcmNlcHRvci5tb2R1bGUnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9oaWVyYXJjaGljYWwtZGF0ZS1hZGp1c3Qtc3ltYm9sJztcclxuIl19
|
|
@@ -4,9 +4,9 @@ import { NgModule } from '@angular/core';
|
|
|
4
4
|
import { HierarchicalDateHttpInterceptor } from './hierarchical-date-http-interceptor';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
export class AngularDateHttpInterceptorModule {
|
|
7
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
8
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
9
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
7
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
8
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, imports: [CommonModule] }); }
|
|
9
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, providers: [
|
|
10
10
|
{
|
|
11
11
|
provide: HTTP_INTERCEPTORS,
|
|
12
12
|
useClass: HierarchicalDateHttpInterceptor,
|
|
@@ -14,7 +14,7 @@ export class AngularDateHttpInterceptorModule {
|
|
|
14
14
|
},
|
|
15
15
|
], imports: [CommonModule] }); }
|
|
16
16
|
}
|
|
17
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, decorators: [{
|
|
18
18
|
type: NgModule,
|
|
19
19
|
args: [{
|
|
20
20
|
imports: [CommonModule],
|
|
@@ -27,4 +27,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.8", ngImpor
|
|
|
27
27
|
],
|
|
28
28
|
}]
|
|
29
29
|
}] });
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1kYXRlLWh0dHAtaW50ZXJjZXB0b3IubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vbGlicy9hbmd1bGFyLWRhdGUtaHR0cC1pbnRlcmNlcHRvci9zcmMvbGliL2FuZ3VsYXItZGF0ZS1odHRwLWludGVyY2VwdG9yLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0saUJBQWlCLENBQUM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zOiBbQ29tbW9uTW9kdWxlXSxcclxuICBwcm92aWRlcnM6IFtcclxuICAgIHtcclxuICAgICAgcHJvdmlkZTogSFRUUF9JTlRFUkNFUFRPUlMsXHJcbiAgICAgIHVzZUNsYXNzOiBIaWVyYXJjaGljYWxEYXRlSHR0cEludGVyY2VwdG9yLFxyXG4gICAgICBtdWx0aTogdHJ1ZSxcclxuICAgIH0sXHJcbiAgXSxcclxufSlcclxuZXhwb3J0IGNsYXNzIEFuZ3VsYXJEYXRlSHR0cEludGVyY2VwdG9yTW9kdWxlIHt9XHJcbiJdfQ==
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
export const HIERARCHICAL_DATE_ADJUST_FUNCTION = new InjectionToken('HIERARCHICAL_DATE_ADJUST_FUNCTION');
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGllcmFyY2hpY2FsLWRhdGUtYWRqdXN0LXN5bWJvbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvYW5ndWxhci1kYXRlLWh0dHAtaW50ZXJjZXB0b3Ivc3JjL2xpYi9oaWVyYXJjaGljYWwtZGF0ZS1hZGp1c3Qtc3ltYm9sLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFL0MsTUFBTSxDQUFDLE1BQU0saUNBQWlDLEdBQUcsSUFBSSxjQUFjLENBRWpFLG1DQUFtQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJbmplY3Rpb25Ub2tlbiB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xyXG5cclxuZXhwb3J0IGNvbnN0IEhJRVJBUkNISUNBTF9EQVRFX0FESlVTVF9GVU5DVElPTiA9IG5ldyBJbmplY3Rpb25Ub2tlbjxcclxuICAob2JqOiB1bmtub3duKSA9PiB2b2lkXHJcbj4oJ0hJRVJBUkNISUNBTF9EQVRFX0FESlVTVF9GVU5DVElPTicpO1xyXG4iXX0=
|
|
@@ -41,13 +41,13 @@ export class HierarchicalDateHttpInterceptor {
|
|
|
41
41
|
return event;
|
|
42
42
|
}));
|
|
43
43
|
}
|
|
44
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
45
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
44
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: HierarchicalDateHttpInterceptor, deps: [{ token: HIERARCHICAL_DATE_ADJUST_FUNCTION }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
45
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: HierarchicalDateHttpInterceptor }); }
|
|
46
46
|
}
|
|
47
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
47
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: HierarchicalDateHttpInterceptor, decorators: [{
|
|
48
48
|
type: Injectable
|
|
49
|
-
}], ctorParameters:
|
|
49
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
50
50
|
type: Inject,
|
|
51
51
|
args: [HIERARCHICAL_DATE_ADJUST_FUNCTION]
|
|
52
|
-
}] }]
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
52
|
+
}] }] });
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGllcmFyY2hpY2FsLWRhdGUtaHR0cC1pbnRlcmNlcHRv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cyBBcHBNb2R1bGUgeyB9XHJcbiAqIGBgYFxyXG4gKi9cclxuQEluamVjdGFibGUoKVxyXG5leHBvcnQgY2xhc3MgSGllcmFyY2hpY2FsRGF0ZUh0dHBJbnRlcmNlcHRvciBpbXBsZW1lbnRzIEh0dHBJbnRlcmNlcHRvciB7XHJcbiAgY29uc3RydWN0b3IoXHJcbiAgICBASW5qZWN0KEhJRVJBUkNISUNBTF9EQVRFX0FESlVTVF9GVU5DVElPTilcclxuICAgIHByaXZhdGUgYWRqdXN0RGF0ZXM6IChvYmo6IHVua25vd24pID0+IHZvaWRcclxuICApIHt9XHJcblxyXG4gIGludGVyY2VwdChcclxuICAgIHJlcTogSHR0cFJlcXVlc3Q8dW5rbm93bj4sXHJcbiAgICBuZXh0OiBIdHRwSGFuZGxlclxyXG4gICk6IE9ic2VydmFibGU8SHR0cEV2ZW50PHVua25vd24+PiB7XHJcbiAgICByZXR1cm4gbmV4dC5oYW5kbGUocmVxKS5waXBlKFxyXG4gICAgICBtYXAoKGV2ZW50OiBIdHRwRXZlbnQ8dW5rbm93bj4pID0+IHtcclxuICAgICAgICBpZiAoZXZlbnQgaW5zdGFuY2VvZiBIdHRwUmVzcG9uc2UpIHtcclxuICAgICAgICAgIHRoaXMuYWRqdXN0RGF0ZXMoZXZlbnQuYm9keSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBldmVudDtcclxuICAgICAgfSlcclxuICAgICk7XHJcbiAgfVxyXG59XHJcbiJdfQ==
|
|
@@ -44,20 +44,20 @@ class HierarchicalDateHttpInterceptor {
|
|
|
44
44
|
return event;
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
48
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
47
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: HierarchicalDateHttpInterceptor, deps: [{ token: HIERARCHICAL_DATE_ADJUST_FUNCTION }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
48
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: HierarchicalDateHttpInterceptor }); }
|
|
49
49
|
}
|
|
50
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: HierarchicalDateHttpInterceptor, decorators: [{
|
|
51
51
|
type: Injectable
|
|
52
|
-
}], ctorParameters:
|
|
52
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
53
53
|
type: Inject,
|
|
54
54
|
args: [HIERARCHICAL_DATE_ADJUST_FUNCTION]
|
|
55
|
-
}] }]
|
|
55
|
+
}] }] });
|
|
56
56
|
|
|
57
57
|
class AngularDateHttpInterceptorModule {
|
|
58
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
59
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
60
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
58
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
59
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, imports: [CommonModule] }); }
|
|
60
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, providers: [
|
|
61
61
|
{
|
|
62
62
|
provide: HTTP_INTERCEPTORS,
|
|
63
63
|
useClass: HierarchicalDateHttpInterceptor,
|
|
@@ -65,7 +65,7 @@ class AngularDateHttpInterceptorModule {
|
|
|
65
65
|
},
|
|
66
66
|
], imports: [CommonModule] }); }
|
|
67
67
|
}
|
|
68
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
68
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AngularDateHttpInterceptorModule, decorators: [{
|
|
69
69
|
type: NgModule,
|
|
70
70
|
args: [{
|
|
71
71
|
imports: [CommonModule],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaskothebeast-angular-date-http-interceptor.mjs","sources":["../../../../
|
|
1
|
+
{"version":3,"file":"adaskothebeast-angular-date-http-interceptor.mjs","sources":["../../../../libs/angular-date-http-interceptor/src/lib/hierarchical-date-adjust-symbol.ts","../../../../libs/angular-date-http-interceptor/src/lib/hierarchical-date-http-interceptor.ts","../../../../libs/angular-date-http-interceptor/src/lib/angular-date-http-interceptor.module.ts","../../../../libs/angular-date-http-interceptor/src/adaskothebeast-angular-date-http-interceptor.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport const HIERARCHICAL_DATE_ADJUST_FUNCTION = new InjectionToken<\r\n (obj: unknown) => void\r\n>('HIERARCHICAL_DATE_ADJUST_FUNCTION');\r\n","import {\r\n HttpEvent,\r\n HttpHandler,\r\n HttpInterceptor,\r\n HttpRequest,\r\n HttpResponse,\r\n} from '@angular/common/http';\r\nimport { Inject, Injectable } from '@angular/core';\r\nimport { Observable } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\n\r\nimport { HIERARCHICAL_DATE_ADJUST_FUNCTION } from './hierarchical-date-adjust-symbol';\r\n\r\n/**\r\n * HttpInterceptor that converts ISO 8601 date strings to Date objects in the response body.\r\n *\r\n * ```ts\r\n * import { HIERARCHICAL_DATE_ADJUST_FUNCTION } from 'my-library'; // Adjust this import as needed\r\n * // choose one function from below depending on library which you use for date manipulation\r\n * import { hierarchicalConvertToDate } from '@adaskothebeast/hierarchical-convert-to-date';\r\n * import { hierarchicalConvertToDateFns } from '@adaskothebeast/hierarchical-convert-to-date-fns';\r\n * import { hierarchicalConvertToDayjs } from '@adaskothebeast/hierarchical-convert-to-dayjs';\r\n * import { hierarchicalConvertToJsJoda } from '@adaskothebeast/hierarchical-convert-to-js-joda';\r\n * import { hierarchicalConvertToLuxon } from '@adaskothebeast/hierarchical-convert-to-luxon';\r\n * import { hierarchicalConvertToMoment } from '@adaskothebeast/hierarchical-convert-to-moment';\r\n *\r\n * @NgModule({\r\n * imports: [\r\n * // ...\r\n * MyLibraryModule,\r\n * ],\r\n * providers: [\r\n * { provide: HIERARCHICAL_DATE_ADJUST_FUNCTION, useValue: hierarchicalConvertToDate },\r\n * // other providers...\r\n * ]\r\n * })\r\n * export class AppModule { }\r\n * ```\r\n */\r\n@Injectable()\r\nexport class HierarchicalDateHttpInterceptor implements HttpInterceptor {\r\n constructor(\r\n @Inject(HIERARCHICAL_DATE_ADJUST_FUNCTION)\r\n private adjustDates: (obj: unknown) => void\r\n ) {}\r\n\r\n intercept(\r\n req: HttpRequest<unknown>,\r\n next: HttpHandler\r\n ): Observable<HttpEvent<unknown>> {\r\n return next.handle(req).pipe(\r\n map((event: HttpEvent<unknown>) => {\r\n if (event instanceof HttpResponse) {\r\n this.adjustDates(event.body);\r\n }\r\n return event;\r\n })\r\n );\r\n }\r\n}\r\n","import { CommonModule } from '@angular/common';\r\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\r\nimport { NgModule } from '@angular/core';\r\n\r\nimport { HierarchicalDateHttpInterceptor } from './hierarchical-date-http-interceptor';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n providers: [\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: HierarchicalDateHttpInterceptor,\r\n multi: true,\r\n },\r\n ],\r\n})\r\nexport class AngularDateHttpInterceptorModule {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A,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,YATjC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;AASX,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,EARhC,SAAA,EAAA;AACT,YAAA;AACE,gBAAA,OAAO,EAAE,iBAAiB;AAC1B,gBAAA,QAAQ,EAAE,+BAA+B;AACzC,gBAAA,KAAK,EAAE,IAAI;AACZ,aAAA;AACF,SAAA,EAAA,OAAA,EAAA,CAPS,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FASX,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAV5C,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,YAAY,CAAC;AACvB,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,QAAQ,EAAE,+BAA+B;AACzC,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA;AACF,iBAAA,CAAA;;;ACfD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaskothebeast/angular-date-http-interceptor",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Adam Pluciński <adaskothebeast@gmail.com> (https://github.com/adaskothebeast)",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/AdaskoTheBeAsT/date-interceptors.git"
|
|
8
9
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/AdaskoTheBeAsT/date-interceptors/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/AdaskoTheBeAsT/date-interceptors",
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@angular/common": "^17.0.8",
|
|
16
|
+
"@angular/core": "^17.0.8",
|
|
17
|
+
"rxjs": "^7.8.1"
|
|
11
18
|
},
|
|
12
19
|
"sideEffects": false,
|
|
13
20
|
"module": "fesm2022/adaskothebeast-angular-date-http-interceptor.mjs",
|
|
@@ -22,5 +29,8 @@
|
|
|
22
29
|
"esm": "./esm2022/adaskothebeast-angular-date-http-interceptor.mjs",
|
|
23
30
|
"default": "./fesm2022/adaskothebeast-angular-date-http-interceptor.mjs"
|
|
24
31
|
}
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"tslib": "^2.3.0"
|
|
25
35
|
}
|
|
26
36
|
}
|