37 Commits

Author SHA1 Message Date
Kevin Foniciello
75aa9cfefd
feat: add stale flag in request return object (#843)
* feature: added stale flag in request return object

* feature: added stale flag in request return object

* feat: added stale flag in request return object

* feat: added stale flag in request return object

* chore: fixed lint issues
2024-08-03 20:52:56 -03:00
Denis
2425b4dc9b
feat: clear storage method (#848) 2024-06-04 22:47:10 -03:00
Edwin Veldhuizen
6cba59cc1c
[must-revalidate] properly revalidate based on eTag (#824)
* [must-revalidate] implement logic to properly revalidate requests with must-revalidate cache-control header

* [lint] fix sorting of imports

* [pull 824] apply feedback

---------

Co-authored-by: Edwin Veldhuizen <edwin@pxr.nl>
2024-04-23 13:06:04 -03:00
Arthur Fiorette
ed99d775bb
feat: correct ESM and CJS support, move to microbundle. (#764) 2024-01-18 23:48:33 -03:00
Arthur Fiorette
db00789433
style: linted code 2023-11-16 03:34:03 -03:00
Arthur Fiorette
eefc98c6c0
perf: faster tests 2023-11-16 03:33:24 -03:00
Arthur Fiorette
ecbc27e466
style: linted code 2023-11-16 03:26:37 -03:00
Arthur Fiorette
dd8f634d75
feat: testing with tsx and c8 2023-09-30 14:57:22 -03:00
arthurfiorette
2cc948d531
feat: moved tests to node:test (#628) 2023-09-03 15:53:58 -03:00
Benjamin Hallion
6407cadb0f
feat: 'cloneData' option to buildMemoryStorage (#581)
* Add 'storeClone' option to buildMemoryStorage function

* fix lint issue

* fix lint issue

* add test for new storeClone option

* fix linter issue

* update comment

* update code according to review

* fix test

* Update src/storage/memory.ts

Add this comment to code coverage skip the structuredClone test

Co-authored-by: Arthur Fiorette <github@arthur.place>

* Update test/storage/memory.test.ts

Co-authored-by: Arthur Fiorette <github@arthur.place>

* fix test

* fix indent

* Update src/storage/memory.ts

* Update test/storage/memory.test.ts

* Update test/storage/memory.test.ts

* Update test/storage/memory.test.ts

* Update test/storage/memory.test.ts

* refactor: docs and more

---------

Co-authored-by: Arthur Fiorette <github@arthur.place>
Co-authored-by: arthurfiorette <arthur.fiorette@gmail.com>
2023-07-01 19:35:53 -03:00
arthurfiorette
c7dab4fa57
chore: updated dependencies 2023-06-09 13:22:44 -03:00
arthurfiorette
82182bf7f8
fix: correct canStale checks (#543) 2023-06-09 13:10:06 -03:00
arthurfiorette
ebd400bfa4
feat: max entries on memory storage #539 2023-05-25 13:14:11 -03:00
arthurfiorette
7731d7e52b fix: lint 2023-04-09 12:09:28 -03:00
arthurfiorette
083f4b7f4d fix: test open handles 2023-03-27 19:31:42 -03:00
arthurfiorette
72de39c4d3 feat: memory storage cleanup 2023-03-19 19:30:19 -03:00
Dimitris-Rafail Katsampas
ee25b394da
chore: default prefix parameter for web storage (#425)
* chore: Added default prefix param for web storage

* chore: Minor default prefix correction

* test: add test

Co-authored-by: arthurfiorette <arthur.fiorette@gmail.com>
2022-12-11 19:00:32 -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
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
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
Christos Kopanos
6db89530c1
feat: handle web storage DOMExceptions (#148) 2022-02-21 14:10:32 -03:00
arthurfiorette
0ba6025fb5
feat: debug mode & fixed tests 2022-01-23 16:13:22 -03:00
arthurfiorette
ff73ad5c69
fix: await unawaited promises and eslint more severe 2022-01-10 13:30:31 -03:00
arthurfiorette
ed1e163472
chore: bundles exports everything and webpack bundles everything 2022-01-07 15:45:06 -03:00
arthurfiorette
567c1b2477
refactor: allow storages not return promises 2022-01-04 15:15:27 -03:00
arthurfiorette
bafe1de98c
refactor: modified and simplified storages 2022-01-02 20:30:00 -03:00
arthurfiorette
6929b021e0
style: fixed prettier plugin order 2021-12-11 10:43:11 -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
Hazork
6e6100b86a fix: fixed isCacheValid function and added tests 2021-10-25 15:58:04 -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
f8adcc4352 fix: force import type to help compilation tools 2021-09-26 16:24:33 -03:00
Hazork
33b8dcd58b refactor!: updated all exports 2021-09-21 12:01:47 -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