fix(api docs): Added api docs and first docs

This commit is contained in:
Chris Troutner
2019-06-18 17:26:27 -07:00
parent 07e415f307
commit c915aff436
5 changed files with 51 additions and 11 deletions
+3 -1
View File
@@ -76,7 +76,9 @@ app.enable("trust proxy")
app.set("views", path.join(__dirname, "views"))
app.set("view engine", "jade")
app.use("/public", express.static(`${__dirname}/public`))
// Mount the docs
app.use("/docs", express.static(`${__dirname}/../docs`))
app.use(logger("dev"))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
+14 -7
View File
@@ -4,9 +4,9 @@
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<title>BCH API</title>
<meta name="description" content="BCH API">
<meta name="author" content="Chris Troutner">
<link rel="stylesheet" href="css/styles.css?v=1.0">
@@ -18,10 +18,17 @@
This web server is based on <a href="https://rest.bitcoin.com">rest.bitcoin.com</a>.
Go there to view an interactive UI of the REST API endpoints.
</p>
<p>
View the API documentation
on <a href="https://developer.bitcoin.com/rest/docs/getting-started">developer.bitcoin.com</a>.
</p>
<ul>
<li>
<a href="/docs">
View the BCH-API documentation
</a>
</li>
<li>
View the original rest.bitcoin.com API documentation
on <a href="https://developer.bitcoin.com/rest/docs/getting-started">developer.bitcoin.com</a>.
</li>
</ul>
<script src="js/scripts.js"></script>
</body>
+10
View File
@@ -61,6 +61,16 @@ async function balanceFromBitcore(thisAddress) {
}
}
/**
* @api {get} /bitcore/balance/:address Get BCH balance for an address
* @apiName GetBalance
* @apiGroup Bitcore
*
* @apiParam {String} address Bitcoin Cash address.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
// GET handler for single balance
async function balanceSingle(req, res, next) {
try {
+23 -2
View File
@@ -13,13 +13,34 @@ const util = require("util")
util.inspect.defaultOptions = { depth: 1 }
router.get("/", root)
router.get("/getInfo", getInfo)
router.get("/getinfo", getInfo)
function root(req, res, next) {
return res.json({ status: "control" })
}
// Execute the RPC getinfo call.
/**
* @api {get} /control/getinfo Get full node info
* @apiName GetInfo
* @apiGroup Control
* @apiDescription RPC call which gets basic full node information.
*
* @apiExample Example usage:
* curl -X GET "http://localhost:5000/v3/control/getinfo" -H "accept: application/json"
*
* @apiSuccess {Object} object Object containing data
* @apiSuccess {Number} object.version Full node version
* @apiSuccess {Number} object.protocolversion Protocol version
* @apiSuccess {Number} object.blocks Current block
* @apiSuccess {Number} object.timeoffset ?
* @apiSuccess {Number} object.connections Number of connected peers
* @apiSuccess {String} object.proxy ?
* @apiSuccess {Number} object.difficulty Current difficulty setting
* @apiSuccess {Boolean} object.testnet testnet = true, mainnet = false
* @apiSuccess {Number} object.paytxfee ?
* @apiSuccess {Number} object.relayfee ?
* @apiSuccess {String} object.errors ?
*/
async function getInfo(req, res, next) {
const {
BitboxHTTP,