UNPKG

@vercel/fetch-cached-dns

Version:

A decorator on top of `fetch` that caches the DNS query of the `hostname` of the passed URL

39 lines 1.71 kB
{ "name": "@vercel/fetch-cached-dns", "version": "2.1.2", "description": "A decorator on top of `fetch` that caches the DNS query of the `hostname` of the passed URL", "license": "MIT", "main": "index.js", "types": "index.d.ts", "files": [ "index.js", "index.d.ts", "util.js" ], "repository": { "type": "git", "url": "https://github.com/vercel/fetch.git", "directory": "packages/fetch-cached-dns" }, "contributors": [ "Nathan Rajlich <nate@vercel.com>", "Ethan Arrowood <ethan.arrowood@vercel.com>" ], "dependencies": { "@types/node-fetch": "^2.6.1", "@zeit/dns-cached-resolve": "^2.1.2" }, "peerDependencies": { "node-fetch": "^2.6.1" }, "devDependencies": { "async-listen": "^1.2.0", "jest": "^27.5.1", "node-fetch": "^2.6.1" }, "scripts": { "test": "jest test", "lint": "cd ../.. && pnpm eslint packages/fetch-cached-dns/**/*.js" }, "readme": "# @vercel/fetch-cached-dns\n\n[![Build Status](https://github.com/vercel/fetch/workflows/CI/badge.svg)](https://github.com/vercel/fetch/actions?workflow=CI)\n\nA decorator on top of `fetch` that caches the DNS query of the `hostname` of the passed URL.\n\n## How to use\n\n```js\nconst fetch = require('@vercel/fetch-cached-dns')(require('node-fetch'));\n```\n\nSince this implementation is implementing redirects we are providing an `onRedirect` extra\noption to the `fetch` call that gets called with the response object and the options that\nwill be used for the next request. This allows to access the request from outside and to\nmodify the options.\n\n_NOTE: if the fetch implementation is not supplied, it will attempt to use peerDep `node-fetch`_\n" }