106 Commits

Author SHA1 Message Date
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
f30e2622dd
refactor: removed "abstract" buildInterceptor function 2022-01-08 12:56:55 -03:00
arthurfiorette
cd2f14c446
refactor: removed classes to decrease bundle size 2022-01-08 12:27:52 -03:00
arthurfiorette
79ce1926d2
refactor: prefer unknown over any and removed find method from storages 2022-01-07 15:24:41 -03:00
Arthur Fiorette
25b34e5d11
docs: documentation at axios-cache-interceptor.js.org (#108) 2022-01-06 18:44:36 -03:00
arthurfiorette
ce2f5976bc
fix: proper generic usage to type deep properties 2022-01-04 15:27:30 -03:00
arthurfiorette
1e87549eb6
feat: allow ttl to be defined based on the response 2022-01-03 10:00:39 -03:00
arthurfiorette
c57916fd67
refactor: extracted static functions to a single file 2022-01-03 09:14:47 -03:00
arthurfiorette
4a0a99ff28
refactor: prevent confusion by renaming createCache to useCache 2021-12-30 13:54:23 -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
b4ad24de48
refactor: made some methods static and public 2021-12-11 10:42:26 -03:00
arthurfiorette
07ec645a9d
perf: removed tslib and typed-core in favor of fast-defer 2021-12-08 16:46:15 -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
Arthur Fiorette
92b9ed7abf
feat: more headers supports, tests and must-revalidate fix (#51)
* feat: must-revalidate and headers enum
* test: added more tests
* test: test and code fixes
* test: more tests
2021-11-11 14:16:37 -03:00
Hazork
99906e57b9 deps: bump axios to v0.24 2021-10-28 11:40:15 -03:00
Hazork
f141b2e680 refactor: externalized cache eviction predicate 2021-10-25 15:30:55 -03:00
Hazork
3ed92c8cc8 style: prettified code 2021-10-12 19:58:31 -03:00
Hazork
b42d3f13d7 refactor: more type and naming refactors 2021-10-12 19:58:00 -03:00
Hazork
12a5032b98 fix: generic spaghetti that axios brought 2021-10-12 19:17:52 -03:00
Hazork
75deccf57d feat: preserve response status codes and use response.cached 2021-10-12 12:12:32 -03:00
Hazork
0605ad8c9f refactor: eslint more strict 2021-10-12 09:24:26 -03:00
Hazork
2fa2557040 refactor: cacheUpdater as generic function 2021-10-12 09:19:59 -03:00
Hazork
52689e24f4 fix: removed implict never 2021-10-09 14:36:36 -03:00
Arthur Fiorette
7d5257eee1 fix: delete waiting object after resolving it 2021-09-30 17:52:10 -03:00
Hazork
9d33ad61d0 refactor: removed double if 2021-09-26 16:42:11 -03:00
Hazork
f8adcc4352 fix: force import type to help compilation tools 2021-09-26 16:24:33 -03:00
Hazork
c70bf3ac41 refactor: renamed interceptor apply method 2021-09-26 15:50:15 -03:00
Hazork
d96a9dc5f0 style: updated prettier config 2021-09-21 12:56:32 -03:00
Hazork
5b6d14f314 refactor: removed symbol support and more tests 2021-09-20 12:20:35 -03:00
Hazork
70e5c07ff3 refactor: concurreny fixes and refactored deferred
Also changed format settings,
fixed AxiosResponse types
and coded more tests
2021-09-20 12:04:40 -03:00
Hazork
1490bfc30b fix: concurrent requests not beeing cached 2021-09-19 20:14:44 -03:00
Hazork
6e61c0d5db refactor: renamed status constants 2021-09-19 19:31:33 -03:00
Hazork
f1033a5959 refactor: interceptors in classes 2021-09-19 19:06:15 -03:00
Hazork
1f88779e46 fix: axios headers are lowercased 2021-09-16 19:11:45 -03:00
Hazork
4ad803ec0b feat: use cache: false to ignore caching 2021-09-15 20:22:51 -03:00
Hazork
84dc522b87 refactor: init request and response tests 2021-09-13 19:20:31 -03:00
Hazork
be5ee1ea8b refactor: ttl and createdAt instead of maxAge and storage takes care of staled entries 2021-09-13 16:05:37 -03:00
Hazork
2bbc9cb858 fix: fixed a log of bugs and added unit tests 2021-09-13 12:08:43 -03:00
Hazork
0d4854db83 fix: interpretHeader name conflict 2021-09-11 13:03:35 -03:00
Hazork
6ae6d8f7e5 style: prettified code 2021-09-11 12:55:28 -03:00
Hazork
892dab4a12 feat: better cache predicate 2021-09-11 12:50:11 -03:00
Hazork
d2c2a56735 refactor: eslint more strict and some minor refactors 2021-09-11 12:18:32 -03:00
Hazork
ce2b7ecb4b refactor: externalized the header interceptor 2021-09-11 10:21:53 -03:00
Hazork
211dd503f4 refactor: moved all "utils" to one folder 2021-09-11 09:09:50 -03:00
Hazork
ab051fc698 refactor: save all deferred to cache.waiting instead of in the storage 2021-09-10 10:39:53 -03:00
Hazork
29d79d5c84 refactor: axios.defaults.cache required 2021-09-10 09:54:30 -03:00