78 Commits

Author SHA1 Message Date
arthurfiorette
268fccb935
feat: override cache option 2022-06-05 11:26:00 -03:00
arthurfiorette
d87307ae93
feat: remove remnant x-axios-headers from server response 2022-06-05 09:50:02 -03:00
dependabot[bot]
ce5900b23c
chore(deps-dev): bump @types/jest from 27.5.1 to 28.1.0 (#252) 2022-06-03 03:30:12 +00:00
Heiko Rothkranz
728b69d71a
fix: Interpret max-age=0 as a valid cache-control header (#253)
* fix: Interpret `max-age=0` as a valid `cache-control` header

* tests: added max-age=0 test

* fix: fixed linting

Co-authored-by: arthurfiorette <arthur.fiorette@gmail.com>
2022-06-02 21:57:51 -03:00
arthurfiorette
f4f4be1cd2
chore(deps): update jest to 28 2022-05-07 15:37:52 -03:00
Arthur Fiorette
17682ca0b9
Pass currentRequest on each access to storages (#220) (#226)
* feat: initial working code

* fix: better usage of currentRequest on storages

* feat: added tests
2022-05-01 10:03:30 -03:00
arthurfiorette
0a00778065
fix: fixed bug when a pending request had it cached empty (#165) 2022-03-24 19:03:40 -03:00
arthurfiorette
a0e05e8d30
tests: fixed memory storage clone test 2022-03-11 17:14:40 -03:00
Arthur Fiorette
f699e194f8
fix: memory storage copy data to avoid reference changes (#164)
* tests: added initial unit test

* fix: added fix

* tests: fixed tests

* style: formatted code
2022-03-11 13:29:13 -03:00
arthurfiorette
ab45164287
fix: defaultKeyGenerator keeps response unchanged (#161) 2022-03-03 18:50:43 -03:00
Christos Kopanos
6db89530c1
feat: handle web storage DOMExceptions (#148) 2022-02-21 14:10:32 -03:00
arthurfiorette
ea4ab4c4eb
refactor: added ACI prefix to avoid external conflicts 2022-01-23 16:18:00 -03:00
arthurfiorette
0ba6025fb5
feat: debug mode & fixed tests 2022-01-23 16:13:22 -03:00
arthurfiorette
d14750ee63
refactor: moved header file 2022-01-19 07:48:33 -03:00
arthurfiorette
7217eaff02
fix: removed breaking behaviour 2022-01-18 12:48:49 -03:00
arthurfiorette
66f29c92c7
deps: updated axios to v0.25 2022-01-18 12:25:31 -03:00
arthurfiorette
edb32bdea3
feat: add staleIfError support 2022-01-18 12:06:20 -03:00
arthurfiorette
9379fce100
feat: buildKeyGenerator and ids with req.data by default 2022-01-14 18:46:20 -03:00
arthurfiorette
fa2c6e3204
perf: only execute one generateKey per request 2022-01-13 21:23:36 -03:00
arthurfiorette
6f9ef36e75
fix: include data at keyGenerator (#116) 2022-01-13 20:48:21 -03:00
Arthur Fiorette
4734c5f7a8
build: Yarn v2 and ESM & CJS bundles (#114) 2022-01-13 18:57:50 -03:00
arthurfiorette
ff73ad5c69
fix: await unawaited promises and eslint more severe 2022-01-10 13:30:31 -03:00
arthurfiorette
88d45cc0fb
feat: cache predicate now supports async functions 2022-01-10 13:00:35 -03:00
arthurfiorette
38a5ecd365
refactor: simplified cachePredicate 2022-01-09 17:27:51 -03:00
arthurfiorette
1b93070db4
refactor: used triple equal sign 2022-01-09 13:33:44 -03:00
arthurfiorette
37431a9d34
refactor!: removed isAxiosCacheInterceptor function 2022-01-08 12:57:19 -03:00
arthurfiorette
cd2f14c446
refactor: removed classes to decrease bundle size 2022-01-08 12:27:52 -03:00
arthurfiorette
4f938a4793
tests: splited header interpreter tests into multiple files 2022-01-08 12:26:37 -03:00
arthurfiorette
85336da8b1
docs: fixed baseURL casing in examples & documentation 2022-01-08 12:26:07 -03:00
arthurfiorette
ed1e163472
chore: bundles exports everything and webpack bundles everything 2022-01-07 15:45:06 -03:00
Arthur Fiorette
25b34e5d11
docs: documentation at axios-cache-interceptor.js.org (#108) 2022-01-06 18:44:36 -03:00
arthurfiorette
cfbd601b98
feat: suupport for async CacheUpdater 2022-01-04 15:28:38 -03:00
arthurfiorette
567c1b2477
refactor: allow storages not return promises 2022-01-04 15:15:27 -03:00
arthurfiorette
1e87549eb6
feat: allow ttl to be defined based on the response 2022-01-03 10:00:39 -03:00
arthurfiorette
a7751fd1cb
tests: 100% coverage again 2022-01-03 09:21:16 -03:00
arthurfiorette
c57916fd67
refactor: extracted static functions to a single file 2022-01-03 09:14:47 -03:00
arthurfiorette
4c1e0ec3fc
docs: fixed tsdocs and added storages section 2022-01-03 09:13:43 -03:00
arthurfiorette
bafe1de98c
refactor: modified and simplified storages 2022-01-02 20:30:00 -03:00
arthurfiorette
c32c452190
feat: added isAxiosCacheInterceptor function 2021-12-31 10:05:21 -03:00
arthurfiorette
1e251ddef3
test: added index.development tests 2021-12-30 16:03:00 -03:00
arthurfiorette
4a0a99ff28
refactor: prevent confusion by renaming createCache to useCache 2021-12-30 13:54:23 -03:00
arthurfiorette
065b6eff74
refactor: deprecated useCache in favor of createCache (#95) 2021-12-27 14:25:55 -03:00
arthurfiorette
fec63a84a7
test: added one simple test 2021-12-27 09:05:53 -03:00
arthurfiorette
6e25ba6f97
perf: reduce bundle size and replaced babel by ts-loader 2021-12-26 20:24:14 -03:00
arthurfiorette
a77cde7e22
refactor: better cache predicate function 2021-12-11 12:27:37 -03:00
arthurfiorette
6929b021e0
style: fixed prettier plugin order 2021-12-11 10:43:11 -03:00
arthurfiorette
c3a0fea1bd
refactor: externalized createCacheData function 2021-12-11 10:42:32 -03:00
arthurfiorette
488cd49527
refactor: bundle does not export everything that index has 2021-12-09 14:37:21 -03:00
arthurfiorette
b9b4f7972f
fix: fixed tests 2021-12-08 20:26:10 -03:00
Arthur Fiorette
48e33c5d5a
feat: etag and if-modified-since support (#53)
* feat(WIP): etag and if-modified-since support

* test: fixed test name

* fix: merge response headers

* test: add etag / last-modified tests

* test: add must-revalidate tests

* fix: handle expirationTime 0 as true.

* tests: refactored some tests

* test: added keepIfStale tests

* fix: remove axios error for 304 requests

* fix: possible infinite loop on validateStatus function

* tests: ignore code that is hard test from coverage

* fix: use Last-Modified header for modifiedSince

If-Modified-Since is never sent by a server, it's
a client only header. However Last-Modified is sent
by the server to indicate the last time the returned
version was modified (it might not be the last version
depending on cache configuration on intermediate
servers)

* test: use validateStatus in mock

This more closely match default axios adapter.

* fix: validateStatus handling all cases

* refactor: use cache.createdAt if the last-modified header isn't present

* test: etag with predefined value

* test: added more test cases

* fix: fixed logic in some tests

* docs: initial documentation

* fix: manual values work out of the box

This removes header requirement from server.

* docs: add details to etag and modifiedSince features

* fix: delete custom headers from response

* feat: accept all configurations from global axios

Merging global into local configuration enable user
to use global configuration for all options and remove
the need to check local and global values every time.

* fix: preserve original types from AxiosInstance

The only value axios needs is a URL, and in the second definition of the method, there is already a URL parameter, so it can be undefined.

* Fix: defaults modifiedSince back to false.

Avoids breaking changes.

* docs: fix etag examples

* docs: document internal headers

* refactor: ternary operator :)

* style: prettified code

* test: remove modifiedSince: false in tests since this is the default

* docs: fix headers examples

* docs: fixed example formatting

* tests: split tests into multiple files to test them faster

* docs: correct jsdoc empty object

Co-authored-by: Charly Koza <cka@f4-group.com>
2021-11-15 10:43:20 -03:00