-
Notifications
You must be signed in to change notification settings - Fork 6
7.0.0-beta #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
7.0.0-beta #65
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3f77a39
Upgrade axios and other packages
4bbf403
remove message object from logs, add 429 error mapping
195c377
update CHANGELOG.md
a7b04f4
Upgrade axios and other packages
b1b4d15
Merge branches 'mh/PRC-10715_UpgradeAxios' and 'mh/PRC-10252_SupportN…
1981cb9
Release 7.0.0-beta
bdb2841
remove the deduplication request adapter, add UT for httpClient that …
7f8effe
use types from openapi
4ad9c48
use Record<string, string> for headers,
d00f58c
add default redis storage class
39c3911
add better types to the headers
6e062a5
respect cache control headers and have ttl as fallback
5dfb8e4
details
eb45edb
use buildStorage() directly
56a0777
move redis to devDependencies
38f3ede
Release 7.0.0-beta
2e403c3
comments
60ad861
comments
c99434b
Release 7.0.0-beta
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| yarn lint-staged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { buildStorage, canStale } from 'axios-cache-interceptor'; | ||
| import type { StorageValue } from 'axios-cache-interceptor'; | ||
| // eslint-disable-next-line import/no-extraneous-dependencies | ||
| import { createClient } from 'redis'; | ||
matushudec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const KEY_PREFIX = 'axios-cache-'; | ||
|
|
||
| const MIN_TTL = 60000; | ||
|
|
||
| export default function createRedisStorage(client: ReturnType<typeof createClient>) { | ||
| // source https://axios-cache-interceptor.js.org/guide/storages#node-redis-storage | ||
| return buildStorage({ | ||
| async find(key) { | ||
| const result = await client.get(`${KEY_PREFIX}${key}`); | ||
| return result ? (JSON.parse(result) as StorageValue) : undefined; | ||
| }, | ||
|
|
||
| // eslint-disable-next-line complexity | ||
| async set(key, value, req) { | ||
| await client.set(`${KEY_PREFIX}${key}`, JSON.stringify(value), { | ||
| PXAT: | ||
mmaruniak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // We don't want to keep indefinitely values in the storage if | ||
| // their request don't finish somehow. Either set its value as | ||
| // the TTL or 1 minute (MIN_TTL). | ||
| value.state === 'loading' | ||
| ? Date.now() + | ||
| (req?.cache && typeof req.cache.ttl === 'number' ? req.cache.ttl : MIN_TTL) | ||
| : (value.state === 'stale' && value.ttl) || | ||
| (value.state === 'cached' && !canStale(value)) | ||
| ? value.createdAt + value.ttl! | ||
| : // otherwise, we can't determine when it should expire, so we keep | ||
| // it indefinitely. | ||
| undefined, | ||
| }); | ||
| }, | ||
|
|
||
| async remove(key) { | ||
| await client.del(`${KEY_PREFIX}${key}`); | ||
| }, | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.