Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ If none of the existing caching options meet your needs, you can implement your
```ts
type INodeFetchCacheCache = {
get(key: string): Promise<{
bodyStream: NodeJS.ReadableStream;
bodyStream: ReadableStream;
metaData: NFCResponseMetadata;
} | undefined>;
set(
key: string,
bodyStream: NodeJS.ReadableStream,
bodyStream: ReadableStream,
metaData: NFCResponseMetadata
): Promise<{
bodyStream: NodeJS.ReadableStream;
bodyStream: ReadableStream;
metaData: NFCResponseMetadata;
}>;
remove(key: string): Promise<void | unknown>;
Expand Down Expand Up @@ -163,19 +163,6 @@ if (response.isCacheMiss) {

## Advanced API

### Accessing Node-Fetch Exports

If you need to access `node-fetch` exports (for example you might want to create a Request instance), you can do so by using the `getNodeFetch()` function:

```js
import fetch, { getNodeFetch } from 'node-fetch-cache';

const { Request } = await getNodeFetch();
const response = await fetch(new Request('https://google.com'));
```

You should not import from `node-fetch` directly since it is important that your code is using exports from the same version of `node-fetch` that is being used by `node-fetch-cache` internally.

### Custom Cache Key Function

You can provide custom cache key generation logic to node-fetch-cache by passing a `calculateCacheKey` option to `create()`:
Expand Down
181 changes: 25 additions & 156 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@
"rimraf": "^5.0.5",
"rollup": "^4.9.1",
"tsx": "^4.17.0",
"typescript": "^5.5.4"
"typescript": "^5.8.3"
},
"dependencies": {
"cacache": "^18.0.4",
"formdata-node": "^6.0.3",
"locko": "^1.1.0",
"node-fetch": "3.3.2"
"locko": "^1.1.0"
},
"husky": {
"hooks": {
Expand Down
Loading
Loading