Skip to content

Commit e6145d5

Browse files
committed
wip: removes cache and test files and takes handlerequest from plugin
1 parent facc0a4 commit e6145d5

File tree

6 files changed

+13
-407
lines changed

6 files changed

+13
-407
lines changed

src/lib/cache.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/lib/contentstack.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { httpClient, retryRequestHandler, retryResponseErrorHandler, retryResponseHandler } from '@contentstack/core';
22
import { AxiosRequestHeaders } from 'axios';
3-
import { handleRequest } from './cache';
43
import { Stack as StackClass } from './stack';
54
import { Policy, StackConfig } from './types';
65
import * as Utility from './utils';
@@ -94,11 +93,21 @@ export function stack(config: StackConfig): StackClass {
9493
if (config.logHandler) client.defaults.logHandler = config.logHandler;
9594

9695
if (config.cacheOptions && config.cacheOptions.policy !== Policy.IGNORE_CACHE) {
96+
if (!config.cacheOptions.persistanceStore) {
97+
throw new Error('Persistance store not provided. Please provide persistance store plugin object.');
98+
}
9799
const defaultAdapter = client.defaults.adapter;
98100
client.defaults.adapter = (adapterConfig: any) => {
99101
return new Promise(async (resolve, reject) => {
100-
if (config.cacheOptions) {
101-
await handleRequest(config.cacheOptions, config.apiKey, defaultAdapter, resolve, reject, adapterConfig);
102+
if (config.cacheOptions && config.cacheOptions.persistanceStore) {
103+
await config.cacheOptions.persistanceStore.handleRequest(
104+
config.cacheOptions.policy,
105+
config.apiKey,
106+
defaultAdapter,
107+
resolve,
108+
reject,
109+
adapterConfig
110+
);
102111
}
103112
else {
104113
throw new Error('Persistance store not provided. Please provide persistance store plugin object.');

src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface StackConfig extends HttpClientParams {
3737
}
3838
export interface CacheOptions {
3939
policy: Policy;
40-
storeType?: any;
40+
persistanceStore?: any;
4141
}
4242

4343
export enum Policy {

test/unit/persistance/local-storage.spec.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

test/unit/persistance/memory-storage.spec.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)