make-fetch-happen
Advanced tools
Comparing version 8.0.14 to 9.0.0
{ | ||
"name": "make-fetch-happen", | ||
"version": "8.0.14", | ||
"version": "9.0.0", | ||
"description": "Opinionated, caching, retrying fetch client", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"*.js", | ||
"lib", | ||
"utils" | ||
"lib" | ||
], | ||
@@ -15,6 +13,6 @@ "scripts": { | ||
"prepublishOnly": "git push --follow-tags", | ||
"test": "tap test/*.js", | ||
"test": "tap", | ||
"posttest": "npm run lint", | ||
"eslint": "eslint", | ||
"lint": "npm run eslint -- *.js utils test", | ||
"lint": "npm run eslint -- lib test", | ||
"lintfix": "npm run lint -- --fix" | ||
@@ -40,3 +38,3 @@ }, | ||
"agentkeepalive": "^4.1.3", | ||
"cacache": "^15.0.5", | ||
"cacache": "^15.2.0", | ||
"http-cache-semantics": "^4.1.0", | ||
@@ -52,2 +50,3 @@ "http-proxy-agent": "^4.0.1", | ||
"minipass-pipeline": "^1.2.4", | ||
"negotiator": "^0.6.2", | ||
"promise-retry": "^2.0.1", | ||
@@ -58,19 +57,24 @@ "socks-proxy-agent": "^5.0.0", | ||
"devDependencies": { | ||
"eslint": "^7.14.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint": "^7.26.0", | ||
"eslint-plugin-import": "^2.23.2", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"mkdirp": "^1.0.4", | ||
"nock": "^11.9.1", | ||
"nock": "^13.0.11", | ||
"npmlog": "^4.1.2", | ||
"require-inject": "^1.4.2", | ||
"rimraf": "^2.7.1", | ||
"rimraf": "^3.0.2", | ||
"safe-buffer": "^5.2.1", | ||
"standard-version": "^7.1.0", | ||
"tap": "^14.11.0" | ||
"standard-version": "^9.3.0", | ||
"tap": "^15.0.9" | ||
}, | ||
"engines": { | ||
"node": ">= 10" | ||
}, | ||
"tap": { | ||
"color": 1, | ||
"files": "test/*.js", | ||
"check-coverage": true | ||
} | ||
} |
@@ -23,3 +23,3 @@ # make-fetch-happen | ||
* [`make-fetch-happen` options](#extra-options) | ||
* [`opts.cacheManager`](#opts-cache-manager) | ||
* [`opts.cachePath`](#opts-cache-path) | ||
* [`opts.cache`](#opts-cache) | ||
@@ -39,3 +39,3 @@ * [`opts.proxy`](#opts-proxy) | ||
const fetch = require('make-fetch-happen').defaults({ | ||
cacheManager: './my-cache' // path where cache will be written (and read) | ||
cachePath: './my-cache' // path where cache will be written (and read) | ||
}) | ||
@@ -108,3 +108,3 @@ | ||
const fetch = require('make-fetch-happen').defaults({ | ||
cacheManager: './my-local-cache' | ||
cachePath: './my-local-cache' | ||
}) | ||
@@ -142,3 +142,3 @@ | ||
* [`opts.cacheManager`](#opts-cache-manager) - Cache target to read/write | ||
* [`opts.cachePath`](#opts-cache-path) - Cache target to read/write | ||
* [`opts.cache`](#opts-cache) - `fetch` cache mode. Controls cache *behavior*. | ||
@@ -154,12 +154,6 @@ * [`opts.proxy`](#opts-proxy) - Proxy agent | ||
#### <a name="opts-cache-manager"></a> `> opts.cacheManager` | ||
#### <a name="opts-cache-path"></a> `> opts.cachePath` | ||
Either a `String` or a `Cache`. If the former, it will be assumed to be a `Path` to be used as the cache root for [`cacache`](https://npm.im/cacache). | ||
A string `Path` to be used as the cache root for [`cacache`](https://npm.im/cacache). | ||
If an object is provided, it will be assumed to be a compliant [`Cache` instance](https://developer.mozilla.org/en-US/docs/Web/API/Cache). Only `Cache.match()`, `Cache.put()`, and `Cache.delete()` are required. Options objects will not be passed in to `match()` or `delete()`. | ||
By implementing this API, you can customize the storage backend for make-fetch-happen itself -- for example, you could implement a cache that uses `redis` for caching, or simply keeps everything in memory. Most of the caching logic exists entirely on the make-fetch-happen side, so the only thing you need to worry about is reading, writing, and deleting, as well as making sure `fetch.Response` objects are what gets returned. | ||
You can refer to `cache.js` in the make-fetch-happen source code for a reference implementation. | ||
**NOTE**: Requests will not be cached unless their response bodies are consumed. You will need to use one of the `res.json()`, `res.buffer()`, etc methods on the response, or drain the `res.body` stream, in order for it to be written. | ||
@@ -171,3 +165,5 @@ | ||
* `X-Local-Cache-Key`: Unique cache entry key for this response | ||
* `X-Local-Cache-Mode`: Either `stream` or `buffer` to indicate how the response was read from cacache | ||
* `X-Local-Cache-Hash`: Specific integrity hash for the cached entry | ||
* `X-Local-Cache-Status`: One of `miss`, `hit`, `stale`, `revalidated`, `updated`, or `skip` to signal how the response was created | ||
* `X-Local-Cache-Time`: UTCString of the cache insertion time for the entry | ||
@@ -190,8 +186,4 @@ | ||
fetch('https://registry.npmjs.org/make-fetch-happen', { | ||
cacheManager: './my-local-cache' | ||
cachePath: './my-local-cache' | ||
}) // -> 200-level response will be written to disk | ||
fetch('https://npm.im/cacache', { | ||
cacheManager: new MyCustomRedisCache(process.env.PORT) | ||
}) // -> 200-level response will be written to redis | ||
``` | ||
@@ -240,3 +232,3 @@ | ||
This option follows the standard `fetch` API cache option. This option will do nothing if [`opts.cacheManager`](#opts-cache-manager) is null. The following values are accepted (as strings): | ||
This option follows the standard `fetch` API cache option. This option will do nothing if [`opts.cachePath`](#opts-cache-path) is null. The following values are accepted (as strings): | ||
@@ -256,3 +248,3 @@ * `default` - Fetch will inspect the HTTP cache on the way to the network. If there is a fresh response it will be used. If there is a stale response a conditional request will be created, and a normal request otherwise. It then updates the HTTP cache with the response. If the revalidation request fails (for example, on a 500 or if you're offline), the stale response will be returned. | ||
const fetch = require('make-fetch-happen').defaults({ | ||
cacheManager: './my-cache' | ||
cachePath: './my-cache' | ||
}) | ||
@@ -342,3 +334,2 @@ | ||
* `getaddrinfo ENOTFOUND` and will be assumed to be either an unreachable domain or the user will be assumed offline. If a response is cached, it will be returned immediately. | ||
* `ECONNRESET` currently has no support for restarting. It will eventually be supported but requires a bit more juggling due to streaming. | ||
@@ -345,0 +336,0 @@ If `opts.retry` is `false`, it is equivalent to `{retries: 0}` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
979
13
55790
16
396
+ Addednegotiator@^0.6.2
+ Addednegotiator@0.6.3(transitive)
Updatedcacache@^15.2.0