Removed "make-fetch-happen" package

This commit is contained in:
ポール ウェッブ 2019-01-08 11:25:34 -06:00
parent b134308845
commit 027fbda327
2 changed files with 13 additions and 17 deletions

View file

@ -6,6 +6,7 @@
import asyncHtml from "choo-async/html"; import asyncHtml from "choo-async/html";
import dedent from "dedent"; import dedent from "dedent";
import got from "got";
// U T I L S // U T I L S
@ -14,7 +15,7 @@ import headerSdk from "../components/api/header-sdk";
import redirects from "../data/redirects.json"; import redirects from "../data/redirects.json";
const blockchainApi = "https://cdn.jsdelivr.net/gh/lbryio/lbrycrd@master/contrib/devtools/generated/api_v1.json"; const blockchainApi = "https://cdn.jsdelivr.net/gh/lbryio/lbrycrd@master/contrib/devtools/generated/api_v1.json";
const fetch = require("make-fetch-happen").defaults({ cacheManager: "./cache" }); const cache = new Map();
const sdkApi = "https://cdn.jsdelivr.net/gh/lbryio/lbry@master/docs/api.json"; const sdkApi = "https://cdn.jsdelivr.net/gh/lbryio/lbry@master/docs/api.json";
@ -57,7 +58,7 @@ export default async(state) => {
`; `;
} }
catch (error) { catch(error) {
const redirectUrl = redirects[state.href]; const redirectUrl = redirects[state.href];
return asyncHtml` return asyncHtml`
@ -148,7 +149,7 @@ function createApiSidebar(apiDetails) {
return apiSidebar; return apiSidebar;
} }
function parseApiFile(urlSlug) { async function parseApiFile(urlSlug) {
let apiFileLink; let apiFileLink;
switch(true) { switch(true) {
@ -164,20 +165,16 @@ function parseApiFile(urlSlug) {
break; break;
} }
if (!apiFileLink) return Promise.reject(new Error("Failed to fetch API docs")); if (!apiFileLink)
return Promise.reject(new Error("Failed to fetch API docs"));
return fetch(apiFileLink) const response = await got(apiFileLink, { cache: cache, json: true });
.then(res => {
return res.json(); try {
}) return response.body;
.then(() => { } catch(error) {
return fetch(apiFileLink, { return "Issue loading API documentation";
cache: "no-cache" // forces a conditional request }
});
})
.then(res => {
return res.json().then(body => body);
});
} }
function renderArguments(args) { function renderArguments(args) {

View file

@ -30,7 +30,6 @@
"got": "^9.5.0", "got": "^9.5.0",
"graceful-fs": "^4.1.15", "graceful-fs": "^4.1.15",
"heroku-ssl-redirect": "0.0.4", "heroku-ssl-redirect": "0.0.4",
"make-fetch-happen": "^4.0.1",
"make-promises-safe": "^4.0.0", "make-promises-safe": "^4.0.0",
"markdown-it": "^8.4.2", "markdown-it": "^8.4.2",
"markdown-it-anchor": "^5.0.2", "markdown-it-anchor": "^5.0.2",