Fixed issues with APIs
This commit is contained in:
parent
0d6a3ea80b
commit
ee9535a8b1
6 changed files with 11 additions and 12 deletions
|
@ -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)));
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ title: Sitemap
|
|||
|
||||
- [/](/)
|
||||
- [/api](/api)
|
||||
- [/blockchain](/api/blockchain)
|
||||
- [/protocol](/api/protocol)
|
||||
- [/build](/build)
|
||||
- [/community](/community)
|
||||
- [/contribute](/contribute)
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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(`
|
||||
<div class="api__content__body">
|
||||
|
@ -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 ? "" : "<span>optional</span>" }<span>${arg.type}</span>
|
||||
</div>
|
||||
|
||||
<div class="right">${arg.description.replace(/</g, "<").replace(/>/g, ">")}</div>
|
||||
<div class="right">${typeof arg.description === "string" ? arg.description.replace(/</g, "<").replace(/>/g, ">") : ""}</div>
|
||||
</li>
|
||||
`);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ module.exports = exports = () => async (state) => {
|
|||
html`<link rel="stylesheet" href="/assets/css/style.css"/>`,
|
||||
|
||||
html`<script src="/assets/scripts/vendor/zepto.js"></script>`,
|
||||
pageTitle === "API" ? html`<script src="/assets/scripts/plugins/jets.js"></script>` : "",
|
||||
state.route === "api" || state.route === "api/*" ? html`<script src="/assets/scripts/plugins/jets.js"></script>` : "",
|
||||
html`<script>const ws = new WebSocket(location.origin.replace(/^http/, "ws"));</script>`,
|
||||
html`<script src="/assets/scripts/sockets.js"></script>`
|
||||
]}`;
|
||||
|
|
Loading…
Reference in a new issue