@akanass/ng-universal-transfer-http
Version:
TransferHttpCacheModule installs a Http interceptor that avoids duplicate HttpClient requests on the client
89 lines (88 loc) • 2.52 kB
TypeScript
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { ApplicationRef } from '@angular/core';
import { TransferState } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { TransferHttpCacheConfigService } from '../transfer-http-cache-config/transfer-http-cache-config.service';
export declare class TransferHttpCacheInterceptor implements HttpInterceptor {
private _appRef;
private _transferState;
private _platformId;
private _configService;
private _isCacheActivated;
private _id;
private readonly _serverStateDataStoreKey;
private readonly _lastIdStoreKey;
private readonly _isCacheActivatedStoreKey;
/**
* Class constructor
*/
constructor(_appRef: ApplicationRef, _transferState: TransferState, _platformId: any, _configService: TransferHttpCacheConfigService);
/**
* Initialize cache process
*/
private _initCacheProcess;
/**
* Interceptor process
*/
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
/**
* Function to clean all data in server state
*/
private _cleanServerState;
/**
* Transfer state process
*/
private _transferStateProcess;
/**
* Creates transfer state key's store
*/
private _createKey;
/**
* Function to get state data and create client key for current request
*/
private _clientKey;
/**
* Function to get last id from server
*/
private _getLastId;
/**
* Function to get server state data
*/
private _getServerStateData;
/**
* Function to create server key and store state data for current request
*/
private _serverKey;
/**
* Function to store server state data
*/
private _storeServerStateData;
/**
* Process when key exists in transfer state
*/
private _hasKeyProcess;
/**
* Process when key doesn't exist in transfer state
*/
private _hasNotKeyProcess;
/**
* Creates Headers Map
*/
private _getHeadersMap;
/**
* Function to create sha256 hash
*/
private _createHash;
/**
* Returns HttpRequest with value of header inside url & urlWithParams
*/
private _replaceWithHeader;
/**
* Replace url with header value
*/
private _formatUrlWithHeaderValue;
/**
* Returns the good request object to create hash
*/
private _requestFormatted;
}