diff --git a/package.json b/package.json index c54a260..389d39d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:integration": "mocha test/v3/integration", "coverage": "nyc report --reporter=text-lcov | coveralls", "coverage:report": "export NETWORK=testnet && nyc --reporter=html mocha test/v2/", - "docs": "./node_modules/.bin/apidoc -i src/ -o docs" + "docs": "./node_modules/.bin/apidoc -i src/routes/v3 -o docs" }, "engines": { "node": ">=10.15.1" diff --git a/src/app.js b/src/app.js index 6e9e076..d7fe624 100644 --- a/src/app.js +++ b/src/app.js @@ -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 })) diff --git a/src/public/index.html b/src/public/index.html index d2cc81d..28ed44e 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -4,9 +4,9 @@ - The HTML5 Herald - - + BCH API + + @@ -18,10 +18,17 @@ This web server is based on rest.bitcoin.com. Go there to view an interactive UI of the REST API endpoints.

-

- View the API documentation - on developer.bitcoin.com. -

+ diff --git a/src/routes/v3/bitcore.js b/src/routes/v3/bitcore.js index 70722d6..8867af8 100644 --- a/src/routes/v3/bitcore.js +++ b/src/routes/v3/bitcore.js @@ -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 { diff --git a/src/routes/v3/control.js b/src/routes/v3/control.js index fabc233..a7994c8 100644 --- a/src/routes/v3/control.js +++ b/src/routes/v3/control.js @@ -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,