From 211dd503f42618cc4d448edbf6fdf2425cabf916 Mon Sep 17 00:00:00 2001 From: Hazork Date: Sat, 11 Sep 2021 09:09:50 -0300 Subject: [PATCH] refactor: moved all "utils" to one folder --- src/axios/cache.ts | 2 +- src/axios/types.ts | 2 +- src/interceptors/request.ts | 2 +- src/interceptors/response.ts | 2 +- src/{utils => util}/deferred.ts | 0 src/{interceptors => }/util/interpret-header.ts | 0 src/{utils => util}/key-generator.ts | 0 src/{interceptors => }/util/update-cache.ts | 2 +- 8 files changed, 5 insertions(+), 5 deletions(-) rename src/{utils => util}/deferred.ts (100%) rename src/{interceptors => }/util/interpret-header.ts (100%) rename src/{utils => util}/key-generator.ts (100%) rename src/{interceptors => }/util/update-cache.ts (88%) diff --git a/src/axios/cache.ts b/src/axios/cache.ts index 09b87459..100c9d47 100644 --- a/src/axios/cache.ts +++ b/src/axios/cache.ts @@ -2,7 +2,7 @@ import { AxiosInstance } from 'axios'; import { applyRequestInterceptor } from '../interceptors/request'; import { applyResponseInterceptor } from '../interceptors/response'; import { MemoryStorage } from '../storage/memory'; -import { defaultKeyGenerator } from '../utils/key-generator'; +import { defaultKeyGenerator } from '../util/key-generator'; import { AxiosCacheInstance, CacheInstance, CacheProperties } from './types'; export function createCache( diff --git a/src/axios/types.ts b/src/axios/types.ts index c252ab0d..e5a4c23d 100644 --- a/src/axios/types.ts +++ b/src/axios/types.ts @@ -6,7 +6,7 @@ import type { AxiosResponse, Method } from 'axios'; -import { Deferred } from 'src/utils/deferred'; +import { Deferred } from 'src/util/deferred'; import { CachedResponse, CacheStorage } from '../storage/types'; export type DefaultCacheRequestConfig = AxiosRequestConfig & { diff --git a/src/interceptors/request.ts b/src/interceptors/request.ts index d098b4b4..cb2e1303 100644 --- a/src/interceptors/request.ts +++ b/src/interceptors/request.ts @@ -1,7 +1,7 @@ import { CachedResponse } from 'src/storage/types'; import { AxiosCacheInstance } from '../axios/types'; import { CACHED_RESPONSE_STATUS, CACHED_RESPONSE_STATUS_TEXT } from '../constants'; -import { Deferred } from '../utils/deferred'; +import { Deferred } from '../util/deferred'; export function applyRequestInterceptor(axios: AxiosCacheInstance) { axios.interceptors.request.use(async (config) => { diff --git a/src/interceptors/response.ts b/src/interceptors/response.ts index 83184c70..122f0cba 100644 --- a/src/interceptors/response.ts +++ b/src/interceptors/response.ts @@ -1,6 +1,6 @@ import { AxiosCacheInstance } from '../axios/types'; import { interpretCacheHeader } from './util/interpret-header'; -import { updateCache } from './util/update-cache'; +import { updateCache } from '../util/update-cache'; export function applyResponseInterceptor(axios: AxiosCacheInstance) { axios.interceptors.response.use(async (response) => { diff --git a/src/utils/deferred.ts b/src/util/deferred.ts similarity index 100% rename from src/utils/deferred.ts rename to src/util/deferred.ts diff --git a/src/interceptors/util/interpret-header.ts b/src/util/interpret-header.ts similarity index 100% rename from src/interceptors/util/interpret-header.ts rename to src/util/interpret-header.ts diff --git a/src/utils/key-generator.ts b/src/util/key-generator.ts similarity index 100% rename from src/utils/key-generator.ts rename to src/util/key-generator.ts diff --git a/src/interceptors/util/update-cache.ts b/src/util/update-cache.ts similarity index 88% rename from src/interceptors/util/update-cache.ts rename to src/util/update-cache.ts index b01fe5c2..c89435f2 100644 --- a/src/interceptors/util/update-cache.ts +++ b/src/util/update-cache.ts @@ -1,4 +1,4 @@ -import { AxiosCacheInstance, CacheProperties } from '../../axios'; +import { AxiosCacheInstance, CacheProperties } from '../axios'; export async function updateCache( axios: AxiosCacheInstance,