From ee9535a8b1eaca109618309667c454211bf1eb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=AB=20=E3=82=A6=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=83=96?= Date: Fri, 24 Aug 2018 13:55:35 -0500 Subject: [PATCH] Fixed issues with APIs --- client.js | 3 +-- documents/resources.md | 4 ++-- documents/sitemap.md | 2 ++ package.json | 1 - views/pages/api.js | 11 +++++------ views/partials/head.js | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/client.js b/client.js index 976956c..5ebb41a 100755 --- a/client.js +++ b/client.js @@ -9,7 +9,6 @@ const bundles = require("choo-bundles"); const choo = require("choo"); const data = require("choo-data"); const devtools = require("choo-devtools"); -const redirect = require("choo-redirect"); const ssr = require("choo-ssr"); // V A R I A B L E S @@ -46,7 +45,7 @@ function main() { )); app.route("/", page(require("./views/pages/home")(app))); - app.route("/api", redirect("/api/blockchain")); // This doesn't seem to work... + app.route("/api", page(require("./views/pages/api")(app))); app.route("/api/*", page(require("./views/pages/api")(app))); app.route("/*", page(require("./views/pages/page")(app))); diff --git a/documents/resources.md b/documents/resources.md index bb8f772..95160ef 100644 --- a/documents/resources.md +++ b/documents/resources.md @@ -5,8 +5,8 @@ title: Resources ## Showcase - [Whitepaper](https://lbry-whitepaper.herokuapp.com) -- [Blockchain API](/api/protocol) -- [Daemon API](/api/daemon) +- [Blockchain API](/api/blockchain) +- [Protocol API](/api/protocol) ## Additional Resources diff --git a/documents/sitemap.md b/documents/sitemap.md index 2c0ad3a..de95b6a 100644 --- a/documents/sitemap.md +++ b/documents/sitemap.md @@ -4,6 +4,8 @@ title: Sitemap - [/](/) - [/api](/api) + - [/blockchain](/api/blockchain) + - [/protocol](/api/protocol) - [/build](/build) - [/community](/community) - [/contribute](/contribute) diff --git a/package.json b/package.json index d769a48..4186a70 100755 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "choo-async": "^0.1.1", "choo-bundles": "^0.2.4", "choo-data": "^0.1.1", - "choo-redirect": "^2.0.0", "choo-ssr": "^0.2.1", "choo-websocket": "^2.0.0", "cors": "^2.8.4", diff --git a/views/pages/api.js b/views/pages/api.js index 41d76f6..1717160 100644 --- a/views/pages/api.js +++ b/views/pages/api.js @@ -44,9 +44,8 @@ function createApiContent(apiDetails) { const apiContent = []; for (const apiDetail of apiDetails) { - // console.log(apiDetail); - // console.log("—————"); - const apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns)); + let apiDetailsReturns = ""; + if (apiDetail.returns) apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns)); apiContent.push(`
@@ -87,12 +86,12 @@ function createApiSidebar(apiDetails) { function parseApiFile(urlSlug) { let apiFileLink; - if (urlSlug === "protocol") apiFileLink = process.env.NODE_ENV === "development" ? + if (!urlSlug || urlSlug === "protocol") apiFileLink = process.env.NODE_ENV === "development" ? "https://rawgit.com/lbryio/lbry/master/docs/api.json" : "https://cdn.rawgit.com/lbryio/lbry/5b3103e4/docs/api.json" ; - if (urlSlug === "daemon") apiFileLink = process.env.NODE_ENV === "development" ? + if (urlSlug === "blockchain") apiFileLink = process.env.NODE_ENV === "development" ? "https://rawgit.com/lbryio/lbrycrd/add_api_docs_scripts/contrib/devtools/generated/api_v1.json" : "https://cdn.rawgit.com/lbryio/lbrycrd/add_api_docs_scripts/contrib/devtools/generated/api_v1.json" ; @@ -115,7 +114,7 @@ function renderArguments(args) { ${arg.is_required === true ? "" : "optional" }${arg.type}
-
${arg.description.replace(//g, ">")}
+
${typeof arg.description === "string" ? arg.description.replace(//g, ">") : ""}
`); } diff --git a/views/partials/head.js b/views/partials/head.js index c82fad9..0380a67 100755 --- a/views/partials/head.js +++ b/views/partials/head.js @@ -55,7 +55,7 @@ module.exports = exports = () => async (state) => { html``, html``, - pageTitle === "API" ? html`` : "", + state.route === "api" || state.route === "api/*" ? html`` : "", html``, html`` ]}`;