69 Commits

Author SHA1 Message Date
arthurfiorette
1e87549eb6
feat: allow ttl to be defined based on the response 2022-01-03 10:00:39 -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
4a0a99ff28
refactor: prevent confusion by renaming createCache to useCache 2021-12-30 13:54:23 -03:00
arthurfiorette
27de6292be
style: formatted code 2021-12-27 18:48:26 -03:00
arthurfiorette
065b6eff74
refactor: deprecated useCache in favor of createCache (#95) 2021-12-27 14:25:55 -03:00
arthurfiorette
6929b021e0
style: fixed prettier plugin order 2021-12-11 10:43:11 -03:00
arthurfiorette
b4ad24de48
refactor: made some methods static and public 2021-12-11 10:42:26 -03:00
arthurfiorette
1615f284b3
chore: CacheOptions at the top of the file 2021-12-09 17:50:31 -03:00
arthurfiorette
60ad91e676
feat!: removed createCache function 2021-12-08 20:01:22 -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
b35ae3e574
feat: storage abstractions (#52)
* refactor: better support for different storages

* test: updated tests

* feat: export AxiosStorage

* style: fix linting
2021-11-11 16:25:51 -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
Arthur Fiorette
bf891bdd09 refactor: better typings for axios 0.24 2021-11-05 10:42:45 -03:00
Hazork
0058cd5771 style: prettified code 2021-10-28 11:42:40 -03:00
Hazork
99906e57b9 deps: bump axios to v0.24 2021-10-28 11:40:15 -03:00
Hazork
b42d3f13d7 refactor: more type and naming refactors 2021-10-12 19:58:00 -03:00