{"id":150,"date":"2020-03-25T13:28:58","date_gmt":"2020-03-25T13:28:58","guid":{"rendered":"http:\/\/proterra.me.uk\/nx01\/?p=150"},"modified":"2020-03-25T13:42:11","modified_gmt":"2020-03-25T13:42:11","slug":"quick-access-to-jsdoc-or-other-api-doc","status":"publish","type":"post","link":"https:\/\/proterra.me.uk\/nx01\/blog\/2020\/03\/25\/quick-access-to-jsdoc-or-other-api-doc\/","title":{"rendered":"Quick access to JSDoc or other API doc"},"content":{"rendered":"<h1>Local access to api documentation<\/h1>\n<p>Embed in a npm module with built in webserver, and then <code>npx theDocsModule<\/code> that would start up a local webserver.<\/p>\n<p>The example code I tried:<\/p>\n<pre><code class=\"language-javascript\">#!\/usr\/bin\/env node\nconst handler = require(&#039;serve-handler&#039;);\nconst http = require(&#039;http&#039;);\nconst open = require(&#039;open&#039;); \nconst path = require(&#039;path&#039;);\nconst server = http.createServer((request, response) =&gt; {\n  \/\/ You pass two more arguments for config and middleware\n  \/\/ More details here: https:\/\/github.com\/zeit\/serve-handler#options\n  return handler(request, response,{\n    &quot;public&quot;: path.join(__dirname,&quot;docs\/master&quot;)\n  });\n})\n\nserver.listen(3000, async () =&gt; {\n  console.log(&#039;Running at http:\/\/localhost:3000&#039;);\n  \/\/ Opens the URL in the default browser\n  await open(&#039;http:\/\/localhost:3000&#039;);\n});<\/code><\/pre>\n<p>with these dependencies at the time of writing<\/p>\n<pre><code class=\"language-json\">  \"dependencies\": {\n    \"open\": \"^6.4.0\",\n    \"serve-handler\": \"^6.1.2\"\n  }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Local access to api documentation Embed in a npm module with built in webserver, and then npx theDocsModule that would &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[11],"tags":[12],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-ideas"],"_links":{"self":[{"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/posts\/150"}],"collection":[{"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":3,"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/posts\/150\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/proterra.me.uk\/nx01\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}